From: Neil E. Hodges <47hasbegun@gmail.com> Date: Sat, 19 Mar 2016 10:23:26 +0000 (-0700) Subject: Added proper enabling and disabling of sending RTs to Twitter. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=39ebb64b858b1b3e7fd21c6de82895dfcaec77b3;p=quix0rs-gnu-social.git Added proper enabling and disabling of sending RTs to Twitter. --- diff --git a/classes/Foreign_link.php b/classes/Foreign_link.php index b3757448ad..8388f12e72 100644 --- a/classes/Foreign_link.php +++ b/classes/Foreign_link.php @@ -89,7 +89,7 @@ class Foreign_link extends Managed_DataObject return $flink; } - function set_flags($noticesend, $noticerecv, $replysync, $friendsync) + function set_flags($noticesend, $noticerecv, $replysync, $repeatsync, $friendsync) { if ($noticesend) { $this->noticesync |= FOREIGN_NOTICE_SEND; @@ -109,6 +109,12 @@ class Foreign_link extends Managed_DataObject $this->noticesync &= ~FOREIGN_NOTICE_SEND_REPLY; } + if ($repeatsync) { + $this->noticesync |= FOREIGN_NOTICE_SEND_REPEAT; + } else { + $this->noticesync &= ~FOREIGN_NOTICE_SEND_REPEAT; + } + if ($friendsync) { $this->friendsync |= FOREIGN_FRIEND_RECV; } else { diff --git a/lib/framework.php b/lib/framework.php index 229de8b793..79d171c698 100644 --- a/lib/framework.php +++ b/lib/framework.php @@ -46,6 +46,7 @@ define('PROFILES_PER_MINILIST', 8); define('FOREIGN_NOTICE_SEND', 1); define('FOREIGN_NOTICE_RECV', 2); define('FOREIGN_NOTICE_SEND_REPLY', 4); +define('FOREIGN_NOTICE_SEND_REPEAT', 8); define('FOREIGN_FRIEND_SEND', 1); define('FOREIGN_FRIEND_RECV', 2); diff --git a/plugins/FacebookBridge/actions/facebooksettings.php b/plugins/FacebookBridge/actions/facebooksettings.php index 67dd20e036..9073256d1d 100644 --- a/plugins/FacebookBridge/actions/facebooksettings.php +++ b/plugins/FacebookBridge/actions/facebooksettings.php @@ -213,7 +213,8 @@ class FacebooksettingsAction extends SettingsAction { $replysync = $this->boolean('replysync'); $original = clone($this->flink); - $this->flink->set_flags($noticesync, false, $replysync, false); + // TODO: Allow disabling of repeats + $this->flink->set_flags($noticesync, false, $replysync, true, false); $result = $this->flink->update($original); if ($result === false) { diff --git a/plugins/TwitterBridge/actions/twitterauthorization.php b/plugins/TwitterBridge/actions/twitterauthorization.php index c9b892b640..9ee7e6b899 100644 --- a/plugins/TwitterBridge/actions/twitterauthorization.php +++ b/plugins/TwitterBridge/actions/twitterauthorization.php @@ -237,7 +237,7 @@ class TwitterauthorizationAction extends FormAction // Defaults: noticesync on, everything else off - $flink->set_flags(true, false, false, false); + $flink->set_flags(true, false, false, false, false); $flink_id = $flink->insert(); diff --git a/plugins/TwitterBridge/actions/twittersettings.php b/plugins/TwitterBridge/actions/twittersettings.php index ccdb44fcb9..1fb0e793c6 100644 --- a/plugins/TwitterBridge/actions/twittersettings.php +++ b/plugins/TwitterBridge/actions/twittersettings.php @@ -161,6 +161,12 @@ class TwittersettingsAction extends ProfileSettingsAction $this->flink->noticesync & FOREIGN_NOTICE_SEND_REPLY); $this->elementEnd('li'); $this->elementStart('li'); + $this->checkbox('repeatsync', + // TRANS: Checkbox label. + _m('Send local repeats to Twitter.'), + $this->flink->noticesync & FOREIGN_NOTICE_SEND_REPEAT); + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('friendsync', // TRANS: Checkbox label. _m('Subscribe to my Twitter friends here.'), @@ -265,6 +271,7 @@ class TwittersettingsAction extends ProfileSettingsAction $noticerecv = $this->boolean('noticerecv'); $friendsync = $this->boolean('friendsync'); $replysync = $this->boolean('replysync'); + $repeatsync = $this->boolean('repeatsync'); if (!$this->flink instanceof Foreign_link) { common_log_db_error($this->flink, 'SELECT', __FILE__); @@ -274,7 +281,7 @@ class TwittersettingsAction extends ProfileSettingsAction $original = clone($this->flink); $wasReceiving = (bool)($original->noticesync & FOREIGN_NOTICE_RECV); - $this->flink->set_flags($noticesend, $noticerecv, $replysync, $friendsync); + $this->flink->set_flags($noticesend, $noticerecv, $replysync, $repeatsync, $friendsync); $result = $this->flink->update($original); if ($result === false) { diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php index 6b7e2179e6..ffdee72a97 100644 --- a/plugins/TwitterBridge/twitter.php +++ b/plugins/TwitterBridge/twitter.php @@ -111,7 +111,14 @@ function is_twitter_bound($notice, $flink) { return false; } - $allowedVerbs = array(ActivityVerb::POST, ActivityVerb::SHARE); + $allowedVerbs = array(ActivityVerb::POST); + + // Default behavior: always send repeats + if (empty($flink)) + array_push($allowedVerbs, ActivityVerb::SHARE); + // Otherwise, check to see if repeats are allowed + else if (($flink->noticesync & FOREIGN_NOTICE_SEND_REPEAT) == FOREIGN_NOTICE_SEND_REPEAT) + array_push($allowedVerbs, ActivityVerb::SHARE); // Don't send things that aren't posts or repeats (at least for now) if (!in_array($notice->verb, $allowedVerbs)) {