aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-11-28 00:16:13 -0800
committerfriendica <info@friendica.com>2013-11-28 00:16:13 -0800
commitaab9b30d03e2cad7be2207fa22dcd6ddad224369 (patch)
treeeae68497541e77c9401325434f57a6cd3f0e6400 /util
parent21e465e48ae918b75d011d0fc5de1864bb474edc (diff)
downloadvolse-hubzilla-aab9b30d03e2cad7be2207fa22dcd6ddad224369.tar.gz
volse-hubzilla-aab9b30d03e2cad7be2207fa22dcd6ddad224369.tar.bz2
volse-hubzilla-aab9b30d03e2cad7be2207fa22dcd6ddad224369.zip
synchronise deletion of comments between red and wp
Diffstat (limited to 'util')
-rw-r--r--util/wp/post_to_red/post_to_red.php33
1 files changed, 33 insertions, 0 deletions
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);