diff options
-rw-r--r-- | include/api.php | 10 | ||||
-rw-r--r-- | util/wp/post_to_red/post_to_red.php | 33 | ||||
-rw-r--r-- | version.inc | 2 |
3 files changed, 44 insertions, 1 deletions
diff --git a/include/api.php b/include/api.php index ca5592d08..093839875 100644 --- a/include/api.php +++ b/include/api.php @@ -1101,6 +1101,16 @@ require_once('include/photos.php'); return false; $id = $r[0]['iid']; } + if($_REQUEST['namespace'] && $_REQUEST['comment_id']) { + $r = q("select * from item_id left join item on item.id = item_id.iid where service = '%s' and sid = '%s' and uid = %d and item.id != item.parent limit 1", + dbesc($_REQUEST['namespace']), + dbesc($_REQUEST['comment_id']), + intval($user_info['uid']) + ); + if(! $r) + return false; + $id = $r[0]['iid']; + } } if(! $id) return false; diff --git a/util/wp/post_to_red/post_to_red.php b/util/wp/post_to_red/post_to_red.php index 71ae88aa8..7eb8697ad 100644 --- a/util/wp/post_to_red/post_to_red.php +++ b/util/wp/post_to_red/post_to_red.php @@ -148,6 +148,37 @@ function post_to_red_delete_post($post_id) { } } +function post_to_red_delete_comment($post_id) { + + // The comment may already be destroyed so we can't query it or the parent post. That means + // we have to make a network call for any deleted comment to see if it's registered on Red. + // We really need a "before_delete_comment" action in WP to make + // this more efficient. + + $user_name = post_to_red_get_acct_name(); + $password = post_to_red_get_password(); + $seed_location = post_to_red_get_seed_location(); + $channel = post_to_red_get_channel_name(); + + if ((isset($user_name)) && (isset($password)) && (isset($seed_location))) { + + $message_id = site_url() . '/' . $post_id; + $url = $seed_location . '/api/statuses/destroy'; + + $headers = array('Authorization' => 'Basic '.base64_encode("$user_name:$password")); + $body = array( + 'namespace' => 'wordpress', + 'comment_id' => $message_id, + ); + if($channel) + $body['channel'] = $channel; + + // post: + $request = new WP_Http; + $result = $request->request($url , array( 'method' => 'POST', 'body' => $body, 'headers' => $headers)); + } +} + @@ -259,6 +290,8 @@ add_action('add_meta_boxes', 'post_to_red_post_checkbox'); add_action('save_post', 'post_to_red_post_field_data'); add_action('before_delete_post', 'post_to_red_delete_post'); +add_action('delete_comment', 'post_to_red_delete_comment'); + add_filter('xmlrpc_methods', 'red_xmlrpc_methods'); add_filter('get_avatar', 'post_to_red_get_avatar',10,5); diff --git a/version.inc b/version.inc index 099c10c8d..5a612c8d2 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2013-11-27.510 +2013-11-28.511 |