Skip to content

Commit

Permalink
fix comment link errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jondavidjohn committed Jun 5, 2013
1 parent fe967f3 commit 44cef91
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
2 changes: 2 additions & 0 deletions lib/social/service.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ public function request($account, $api, array $args = array(), $method = 'GET')
$api = apply_filters('social_api_endpoint', $api, $this->_key);
$method = apply_filters('social_api_endpoint_method', $method, $this->_key);
$args = apply_filters('social_api_endpoint_args', $args, $this->_key);
Social::Log("$this->_key - Using Public Key => " . $account->public_key());
Social::Log("$this->_key - Using Hash => " . sha1($account->public_key() . $account->private_key()));
$request = wp_remote_post($proxy, array(
'timeout' => 60, // default of 5 seconds if not set here
'sslverify' => false,
Expand Down
22 changes: 16 additions & 6 deletions lib/social/service/facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,21 @@ public function broadcast($account, $message, array $args = array(), $post_id =
&& in_array($parent_comment->comment_type, self::comment_types())) {

if ($status_id = get_comment_meta($parent_comment->comment_ID, 'social_reply_to_id', true)) {
$parent_status_id = get_comment_meta($comment->comment_parent, 'social_status_id', true);
Social::Log("parent ($comment->comment_parent) status id $parent_status_id");
$args = apply_filters($this->key().'_broadcast_args', $args, $post_id, $comment_id);
$response = $this->request($account, $status_id.'/comments', $args, 'POST');
if ($response !== false && $response->body()->result == 'success') {
// post succeeded, return response
update_comment_meta($comment->comment_ID, 'social_reply_to_id', addslashes_deep($status_id));
update_comment_meta($comment->comment_ID, 'social_status_id', addslashes_deep($parent_status_id));
update_comment_meta($comment->comment_ID, 'social_broadcast_id', addslashes_deep($response->body()->response->id));
Social::Log("Saving Reply");
return $response;
}
}
}

$broadcasted_ids = get_post_meta($comment->comment_post_ID, '_social_broadcasted_ids', true);

// If only 1 account has been posted to
Expand All @@ -117,13 +122,16 @@ public function broadcast($account, $message, array $args = array(), $post_id =
$response = $this->request($account, $status_id.'/comments', $args, 'POST');
if ($response !== false && $response->body()->result == 'success') {
// post succeeded, return response
$response = $this->request($account, $response->body()->response->id, array('fields' => 'can_comment'));
$broadcasted_id = $response->body()->response->id;
$response = $this->request($account, $broadcasted_id, array('fields' => 'can_comment'));
if ($response !== false && $response->body()->result == 'success' && $response->body()->response->can_comment) {
update_comment_meta($comment->comment_ID, 'social_reply_to_id', addslashes_deep($response->body()->response->id));
}
else {
update_comment_meta($comment->comment_ID, 'social_reply_to_id', addslashes_deep($status_id));
}
update_comment_meta($comment->comment_ID, 'social_broadcast_id', addslashes_deep($broadcasted_id));
update_comment_meta($comment->comment_ID, 'social_status_id', addslashes_deep($status_id));
return $response;
}
}
Expand Down Expand Up @@ -168,6 +176,7 @@ public function broadcast($account, $message, array $args = array(), $post_id =
if ($response !== false && $response->body()->result == 'success') {
// post succeeded, return response
update_comment_meta($comment->comment_ID, 'social_reply_to_id', addslashes_deep($response->body()->response->id));
update_comment_meta($comment->comment_ID, 'social_broadcast_id', addslashes_deep($response->body()->response->id));
}
return $response;
}
Expand Down Expand Up @@ -208,7 +217,6 @@ public function aggregate_by_url(&$post, array $urls) {
}

Social_Aggregation_Log::instance($post->ID)->add($this->_key, $result->id, 'url');
$result->reply_to_id = $result->id;
$post->aggregated_ids[$this->_key][] = $result->id;
$post->results[$this->_key][$result->id] = $result;
}
Expand Down Expand Up @@ -270,6 +278,7 @@ public function aggregate_by_api(&$post) {
else {
$result->reply_to_id = $broadcasted_id;
}
$result->status_id = $broadcasted_id;
$post->aggregated_ids[$this->_key][] = $result->id;
$post->results[$this->_key][$result->id] = $result;
}
Expand Down Expand Up @@ -323,7 +332,7 @@ private function search_for_likes(&$account, $id, $parent_id, &$post, &$like_cou
'from_id' => $result->id,
'raw' => $result,
), (array) $result);
$result->id = $id;
$result->status_id = $id;
$post->results[$this->_key][$result->id] = $result;
++$like_count;
}
Expand Down Expand Up @@ -354,7 +363,7 @@ private function get_comment_from_fb_id($fb_parent_id) {
return $wpdb->get_row($wpdb->prepare("
SELECT comment_id
FROM $wpdb->commentmeta AS cm
WHERE cm.meta_key = 'social_status_id'
WHERE cm.meta_key = 'social_broadcast_id'
AND cm.meta_value = %s
", $fb_parent_id));
}
Expand Down Expand Up @@ -445,7 +454,8 @@ public function save_aggregated_comments(&$post) {

update_comment_meta($comment_id, 'social_account_id', addslashes_deep($user_id));
update_comment_meta($comment_id, 'social_profile_image_url', addslashes_deep('https://graph.facebook.com/'.$user_id.'/picture'));
update_comment_meta($comment_id, 'social_status_id', addslashes_deep($result->id));
update_comment_meta($comment_id, 'social_status_id', addslashes_deep($result->status_id));
update_comment_meta($comment_id, 'social_broadcast_id', addslashes_deep($result->id));

if ($result->reply_to_id) {
update_comment_meta($comment_id, 'social_reply_to_id', addslashes_deep($result->reply_to_id));
Expand Down
8 changes: 4 additions & 4 deletions social.php
Original file line number Diff line number Diff line change
Expand Up @@ -1455,10 +1455,10 @@ public function comment_post($comment_ID) {

// Feed posts return id with property, comment posts return raw id
if (isset($response->body()->response->id)) {
update_comment_meta($comment_ID, 'social_status_id', addslashes_deep($response->body()->response->id));
add_comment_meta($comment_ID, 'social_status_id', addslashes_deep($response->body()->response->id), true);
}
else {
update_comment_meta($comment_ID, 'social_status_id', addslashes_deep($response->body()->response));
add_comment_meta($comment_ID, 'social_status_id', addslashes_deep($response->body()->response), true);
}
update_comment_meta($comment_ID, 'social_raw_data', addslashes_deep(base64_encode(json_encode($response->body()->response))));
Social::log(sprintf(__('Broadcasting comment #%s to %s using account #%s COMPLETE.', 'social'), $comment_ID, $service->title(), $account->id()));
Expand Down Expand Up @@ -1550,10 +1550,10 @@ public function wp_set_comment_status($comment_id, $comment_status) {

// Feed posts return id with property, comment posts return raw id
if (isset($response->body()->response->id)) {
update_comment_meta($comment_id, 'social_status_id', addslashes_deep($response->body()->response->id));
add_comment_meta($comment_ID, 'social_status_id', addslashes_deep($response->body()->response->id), true);
}
else {
update_comment_meta($comment_id, 'social_status_id', addslashes_deep($response->body()->response));
add_comment_meta($comment_ID, 'social_status_id', addslashes_deep($response->body()->response), true);
}
update_comment_meta($comment_id, 'social_raw_data', addslashes_deep(base64_encode(json_encode($response->body()->response))));
Social::log(sprintf(__('Broadcasting comment #%s to %s using account #%s COMPLETE.', 'social'), $comment_id, $service->title(), $account->id()));
Expand Down

0 comments on commit 44cef91

Please sign in to comment.