]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix for repeats from the API having null source attribution
authorZach Copley <zach@status.net>
Fri, 7 May 2010 23:32:24 +0000 (16:32 -0700)
committerZach Copley <zach@status.net>
Sat, 8 May 2010 00:22:16 +0000 (17:22 -0700)
actions/apidirectmessagenew.php
actions/apistatusesretweet.php
actions/apistatusesupdate.php
lib/apiaction.php
lib/apiauth.php

index b9ac92d77bfc01bb91f87ec67ddde184b48f8347..65d065648ff0337483a3fd5add842546b2133230 100644 (file)
@@ -52,7 +52,6 @@ require_once INSTALLDIR . '/lib/apiauth.php';
 
 class ApiDirectMessageNewAction extends ApiAuthAction
 {
-    var $source  = null;
     var $other   = null;
     var $content = null;
 
@@ -76,13 +75,6 @@ class ApiDirectMessageNewAction extends ApiAuthAction
             return;
         }
 
-        $this->source = $this->trimmed('source'); // Not supported by Twitter.
-
-        $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
-        if (empty($this->source) || in_array($this->source, $reserved_sources)) {
-            $source = 'api';
-        }
-
         $this->content = $this->trimmed('text');
 
         $this->user  = $this->auth_user;
index 128c881e25aef3979e1f253f1f141f4ac46a07ce..9aa33748544ec5c978453701aacba6265dd20a85 100644 (file)
@@ -79,7 +79,7 @@ class ApiStatusesRetweetAction extends ApiAuthAction
 
         $this->user = $this->auth_user;
 
-        if ($this->user->id == $notice->profile_id) {
+        if ($this->user->id == $this->original->profile_id) {
             $this->clientError(_('Cannot repeat your own notice.'),
                                400, $this->format);
             return false;
index 5f3a447c23867505827e60946fd8c43906fe1e8a..a0a81f3368fa23bb8c333e03e3b002b4da3a8418 100644 (file)
@@ -155,8 +155,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
     var $lat                   = null;
     var $lon                   = null;
 
-    static $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
-
     /**
      * Take arguments for running
      *
@@ -171,19 +169,9 @@ class ApiStatusesUpdateAction extends ApiAuthAction
         parent::prepare($args);
 
         $this->status = $this->trimmed('status');
-        $this->source = $this->trimmed('source');
         $this->lat    = $this->trimmed('lat');
         $this->lon    = $this->trimmed('long');
 
-        // try to set the source attr from OAuth app
-        if (empty($this->source)) {
-            $this->source = $this->oauth_source;
-        }
-
-        if (empty($this->source) || in_array($this->source, self::$reserved_sources)) {
-            $this->source = 'api';
-        }
-
         $this->in_reply_to_status_id
             = intval($this->trimmed('in_reply_to_status_id'));
 
index d35391d4ea25b0e2a411dea0f171cc6bfe2bd6c8..e481a1ef29ebbd151ccc68e3618f9ee9ddd68949 100644 (file)
@@ -126,9 +126,12 @@ class ApiAction extends Action
     var $count     = null;
     var $max_id    = null;
     var $since_id  = null;
+    var $source    = null;
 
     var $access    = self::READ_ONLY;  // read (default) or read-write
 
+    static $reserved_sources = array('web', 'omb', 'ostatus', 'mail', 'xmpp', 'api');
+
     /**
      * Initialization.
      *
@@ -152,6 +155,12 @@ class ApiAction extends Action
             header('X-StatusNet-Warning: since parameter is disabled; use since_id');
         }
 
+        $this->source = $this->trimmed('source');
+
+        if (empty($this->source) || in_array($this->source, self::$reserved_sources)) {
+            $this->source = 'api';
+        }
+
         return true;
     }
 
index 8c39988889d4efb765999b313abae939125d0e53..9c68e27713a1148193c24ea4477de0de0735589c 100644 (file)
@@ -72,7 +72,6 @@ class ApiAuthAction extends ApiAction
 {
     var $auth_user_nickname = null;
     var $auth_user_password = null;
-    var $oauth_source       = null;
 
     /**
      * Take arguments for running, looks for an OAuth request,
@@ -181,7 +180,7 @@ class ApiAuthAction extends ApiAction
 
             // set the source attr
 
-            $this->oauth_source = $app->name;
+            $this->source = $app->name;
 
             $appUser = Oauth_application_user::staticGet('token', $access_token);