Permalink
Browse files

Merge branch 'feature/auto-approve-likes-and-rts' into develop

  • Loading branch information...
jondavidjohn committed Sep 12, 2012
2 parents 3a79784 + d046de0 commit a174c242e5475f9b8c7dc6695b0023259d19dcf3
Showing with 30 additions and 20 deletions.
  1. +2 −2 lib/social/controller/aggregation.php
  2. +15 −8 lib/social/service/facebook.php
  3. +11 −8 lib/social/service/twitter.php
  4. +2 −2 social-twitter.php
@@ -21,7 +21,7 @@ public function action_run() {
Social::log('Aggregation has been disabled, exiting.');
return;
}
-
+
$post = get_post($this->request->query('post_id'));
if ($post === null) {
return;
@@ -65,7 +65,7 @@ public function action_run() {
if (!isset($post->aggregated_ids[$key])) {
$post->aggregated_ids[$key] = array();
}
-
+
if (isset($broadcasted_ids[$key]) and count($broadcasted_ids[$key])) {
$service->aggregate_by_api($post);
@@ -74,7 +74,7 @@ public function get_broadcast_extras($account_id, $post, $args = array()) {
*/
public function broadcast($account, $message, array $args = array(), $post_id = null, $comment_id = null) {
global $post;
- // if post ID is set, this is a broadcast of a post,
+ // if post ID is set, this is a broadcast of a post,
// if the comment ID is set it is a broadcast of a comment
// TODO - add wrapper functions that abstract these actions out to separate methods
@@ -109,7 +109,7 @@ public function broadcast($account, $message, array $args = array(), $post_id =
}
}
}
-
+
// posting with a link, do not include URL in comment.
$format = trim(str_replace('{url}', '', Social::option('comment_broadcast_format')));
$message = $this->format_comment_content($comment, $format);
@@ -227,7 +227,7 @@ public function aggregate_by_api(&$post) {
continue;
}
}
-
+
Social_Aggregation_Log::instance($post->ID)->add($this->_key, $result->id, 'reply', false, $data);
$result->status_id = $broadcasted_id;
$post->results[$this->_key][$result->id] = $result;
@@ -335,6 +335,7 @@ public function save_aggregated_comments(&$post) {
'comment_date' => date('Y-m-d H:i:s', strtotime($result->created_time) + (get_option('gmt_offset') * 3600)),
'comment_date_gmt' => gmdate('Y-m-d H:i:s', strtotime($result->created_time)),
));
+
}
}
else {
@@ -356,7 +357,10 @@ public function save_aggregated_comments(&$post) {
));
$result_id = (isset($result->status_id) ? $result->status_id : $result->id);
- if (($commentdata = $this->allow_comment($commentdata, $result_id, $post)) === false) {
+ if (apply_filters('social_approve_likes_and_retweets', true) && isset($result->like)) {
+ $commentdata['comment_approved'] = 1;
+ }
+ else if (($commentdata = $this->allow_comment($commentdata, $result_id, $post)) === false) {
continue;
}
@@ -375,6 +379,9 @@ public function save_aggregated_comments(&$post) {
$comment_id = 0;
try
{
+ Social::Log('Attempting to save commentdata: :commentdata', array(
+ 'commentdata' => print_r($commentdata, true)
+ ));
$comment_id = wp_insert_comment($commentdata);
update_comment_meta($comment_id, 'social_account_id', addslashes_deep($user_id));
@@ -579,14 +586,14 @@ public static function comment_types_meta() {
'social-facebook-like',
);
}
-
+
public static function social_settings_save($controller) {
// Save Facebook pages
$is_profile = ($controller->request()->post('social_profile') == 'true');
if ($is_profile and !defined('IS_PROFILE_PAGE')) {
define('IS_PROFILE_PAGE', true);
}
-
+
$enabled_pages = $controller->request()->post('social_enabled_pages');
if (!is_array($enabled_pages)) {
$enabled_pages = array();
@@ -606,15 +613,15 @@ public static function social_settings_save($controller) {
}
}
}
-
+
}
foreach ($fb_accounts as $account_id => $account) {
$fb_accounts[$account_id] = $account->as_object();
}
$service->accounts($fb_accounts)->save($is_profile);
}
}
-
+
public static function social_settings_default_accounts($accounts, $controller) {
if (is_array($controller->request()->post('social_default_pages'))) {
if (!isset($accounts['facebook'])) {
@@ -24,7 +24,7 @@
public function max_broadcast_length() {
return 140;
}
-
+
/**
* Any additional parameters that should be passed with a broadcast.
*
@@ -95,7 +95,7 @@ public function aggregate_by_url(&$post, array $urls) {
continue;
}
}
-
+
$result->comment_type = (Social_Twitter::is_retweet(null, $result) ? 'social-twitter-rt' : 'social-twitter');
Social_Aggregation_Log::instance($post->ID)->add($this->_key, $result->id, 'url', false, $data);
@@ -181,9 +181,9 @@ public function aggregate_by_api(&$post) {
continue;
}
// not a reply to a broadcast, or a reply to an aggregated (or broadcast) comment
- if (!isset($broadcasted_ids[$result->in_reply_to_status_id]) &&
+ if (!isset($broadcasted_ids[$result->in_reply_to_status_id]) &&
(
- !isset($post->aggregated_ids[$this->_key]) ||
+ !isset($post->aggregated_ids[$this->_key]) ||
!in_array($result->in_reply_to_status_id, $post->aggregated_ids[$this->_key])
)) {
continue;
@@ -244,8 +244,8 @@ public function save_aggregated_comments(&$post, $skip_approval = false) {
'comment_agent' => 'Social Aggregator',
);
- if ($skip_approval) {
- $commentdata['comment_approved'] = '1';
+ if ($skip_approval || (apply_filters('social_approve_likes_and_retweets', true) && Social_Twitter::is_retweet(null, $result))) {
+ $commentdata['comment_approved'] = 1;
}
else if (($commentdata = $this->allow_comment($commentdata, $result->id, $post)) === false) {
continue;
@@ -267,6 +267,9 @@ public function save_aggregated_comments(&$post, $skip_approval = false) {
$comment_id = 0;
try
{
+ Social::Log('Attempting to save commentdata: :commentdata', array(
+ 'commentdata' => print_r($commentdata, true)
+ ));
$comment_id = wp_insert_comment($commentdata);
update_comment_meta($comment_id, 'social_account_id', addslashes_deep($result->from_user_id));
@@ -345,7 +348,7 @@ public function aggregation_row($type, $item, $username, $id) {
}
return '';
}
-
+
/**
* Parse a Twitter URL and return the tweet ID.
*
@@ -638,7 +641,7 @@ public static function get_comment_author_link($url) {
return $url;
}
-
+
/**
* Comment types for this service.
*
View
@@ -276,7 +276,7 @@ private static function build_hash($text) {
return md5(trim($content));
}
-
+
/**
* Checks for a retweet via twitter API data and user perception.
*
@@ -360,7 +360,7 @@ public static function social_item_output_title($title, $key) {
return $title;
}
-
+
/**
* Add a "reply to" field to broadcast form.
*

0 comments on commit a174c24

Please sign in to comment.