11 Commits aa004d03aa ... 457d32e273

Author SHA1 Message Date
  Mikael Nordfeldth 457d32e273 Merge branch 'takeshitakenji/gnu-social-twitter-repeat-config' into mmn_fixes 6 years ago
  mmn dd8e17a387 Merge branch 'profile' into 'nightly' 6 years ago
  mmn 93524c4be3 Merge branch 'doc-backup-restore-def-vals' into 'nightly' 6 years ago
  mmn 924bcd93e5 Merge branch 'notice_id-xml' into 'nightly' 6 years ago
  Chimo 63f9af307d doc: Update 'backup', 'restore' default values 7 years ago
  Thomas Karpiniec 47cd054976 Use the statusnet namespace for notice_id 7 years ago
  Martin Lyth b0204023c0 Fix the case of a call to sameAs() 7 years ago
  Martin Lyth c9afdae01c Check if we're the current user before retrieving 7 years ago
  Martin Lyth a62755182c Test user equality better in Profile->getUser() 7 years ago
  Martin Lyth d7a29be3ac Change Profile->getUser() to match the current user 7 years ago
  Neil E. Hodges 39ebb64b85 Added proper enabling and disabling of sending RTs to Twitter. 8 years ago

+ 2 - 2
CONFIGURE

@@ -497,9 +497,9 @@ Profile management.
 
 biolimit: max character length of bio; 0 means no limit; null means to use
     the site text limit default.
-backup: whether users can backup their own profiles. Defaults to true.
+backup: whether users can backup their own profiles. Defaults to false.
 restore: whether users can restore their profiles from backup files. Defaults
-	 to true.
+	 to false.
 delete: whether users can delete their own accounts. Defaults to false.
 move: whether users can move their accounts to another server. Defaults
       to true.

+ 7 - 1
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 {

+ 1 - 1
classes/Notice.php

@@ -2220,7 +2220,7 @@ class Notice extends Managed_DataObject
                 $object->selfLink = null;
             }
 
-            $object->extra[] = array('status_net', array('notice_id' => $this->id));
+            $object->extra[] = array('statusnet:notice_id', null, $this->id);
 
             Event::handle('EndActivityObjectFromNotice', array($this, &$object));
         }

+ 8 - 3
classes/Profile.php

@@ -89,9 +89,14 @@ class Profile extends Managed_DataObject
     public function getUser()
     {
         if (!isset($this->_user[$this->id])) {
-            $user = User::getKV('id', $this->id);
-            if (!$user instanceof User) {
-                throw new NoSuchUserException(array('id'=>$this->id));
+            $cur_user = common_current_user();
+            if (($cur_user instanceof User) && $cur_user->sameAs($this)) {
+                $user = $cur_user;
+            } else {
+                $user = User::getKV('id', $this->id);
+                if (!$user instanceof User) {
+                    throw new NoSuchUserException(array('id'=>$this->id));
+                }
             }
             $this->_user[$this->id] = $user;
         }

+ 1 - 0
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);

+ 1 - 1
plugins/ActivityVerbPost/ActivityVerbPostPlugin.php

@@ -77,7 +77,7 @@ class ActivityVerbPostPlugin extends ActivityVerbHandlerPlugin
         $object->content = $notice->getRendered();
         $object->link    = $notice->getUrl();
 
-        $object->extra[] = array('status_net', array('notice_id' => $notice->getID()));
+        $object->extra[] = array('statusnet:notice_id', null, $notice->getID());
 
         return $object;
     }

+ 1 - 1
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();
 

+ 8 - 1
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) {

+ 8 - 1
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)) {