]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Added proper enabling and disabling of sending RTs to Twitter.
authorNeil E. Hodges <47hasbegun@gmail.com>
Sat, 19 Mar 2016 10:23:26 +0000 (03:23 -0700)
committerroot <root@gs.kawa-kun.com>
Mon, 21 Mar 2016 14:12:52 +0000 (07:12 -0700)
classes/Foreign_link.php
lib/framework.php
plugins/FacebookBridge/actions/facebooksettings.php
plugins/TwitterBridge/actions/twitterauthorization.php
plugins/TwitterBridge/actions/twittersettings.php
plugins/TwitterBridge/twitter.php

index b3757448ade7e59f5d04d27fbff555154b8f6cb0..8388f12e72fc192b6b62edf0d5e6c4da45013266 100644 (file)
@@ -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 {
index 229de8b79323f6bf22e3211e42b01ac88c60693b..79d171c698a36cff7b478aedc8f3da18ba53427d 100644 (file)
@@ -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);
index 67dd20e036dfd09a870e88bc56d0e6749e78712e..9073256d1dfbeb7250e577ea3c49fab9dd9cc20a 100644 (file)
@@ -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) {
index c9b892b6408d74ec5b388cf0333704c92699dfae..9ee7e6b899f4553ed4552aec8101f2eb1b2ab5b9 100644 (file)
@@ -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();
 
index ccdb44fcb9869fa524acdbf5ce8cd741bd196a08..1fb0e793c6d2333f78eebf6b4e121179cd0f1353 100644 (file)
@@ -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) {
index 6b7e2179e66d6c4657710df326388a5f3e8b5bf5..ffdee72a9761cc3418afec6cba59cfa5d7dae8d2 100644 (file)
@@ -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)) {