]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/twitapistatuses.php
Merge branch '0.9.x' of git@gitorious.org:laconica/mainline into 0.9.x
[quix0rs-gnu-social.git] / actions / twitapistatuses.php
index 2bc404063846d58f15fdc63b845837aba97b5a1e..e3d366ecc8dddf7f4914faafaa935d1cbfeeea86 100644 (file)
@@ -75,8 +75,8 @@ class TwitapistatusesAction extends TwitterapiAction
     {
         parent::handle($args);
 
+        $this->auth_user = $apidata['user'];
         $user = $this->get_user($apidata['api_arg'], $apidata);
-        $this->auth_user = $user;
 
         if (empty($user)) {
              $this->clientError(_('No such user!'), 404,
@@ -100,8 +100,13 @@ class TwitapistatusesAction extends TwitterapiAction
         $since_id = (int)$this->arg('since_id', 0);
         $since    = $this->arg('since');
 
-        $notice = $user->noticesWithFriends(($page-1)*$count,
-            $count, $since_id, $max_id,$since);
+        if (!empty($this->auth_user) && $this->auth_user->id == $user->id) {
+            $notice = $user->noticeInbox(($page-1)*$count,
+                $count, $since_id, $max_id, $since);
+        } else {
+            $notice = $user->noticesWithFriends(($page-1)*$count,
+                $count, $since_id, $max_id, $since);
+        }
 
         switch($apidata['content-type']) {
         case 'xml':
@@ -368,9 +373,19 @@ class TwitapistatusesAction extends TwitterapiAction
             return;
         }
 
+        // 'id' is an undocumented parameter in Twitter's API. Several
+        // clients make use of it, so we support it too.
+
+        // show.json?id=12345 takes precedence over /show/12345.json
+
         $this->auth_user = $apidata['user'];
-        $notice_id       = $apidata['api_arg'];
-        $notice          = Notice::staticGet($notice_id);
+        $notice_id       = $this->trimmed('id');
+
+        if (empty($notice_id)) {
+            $notice_id   = $apidata['api_arg'];
+        }
+
+        $notice          = Notice::staticGet((int)$notice_id);
 
         if ($notice) {
             if ($apidata['content-type'] == 'xml') {
@@ -381,10 +396,15 @@ class TwitapistatusesAction extends TwitterapiAction
         } else {
             // XXX: Twitter just sets a 404 header and doens't bother
             // to return an err msg
-            $this->clientError(_('No status with that ID found.'),
-                404, $apidata['content-type']);
+            $deleted = Deleted_notice::staticGet($notice_id);
+            if (!empty($deleted)) {
+                $this->clientError(_('Status deleted.'),
+                                   410, $apidata['content-type']);
+            } else {
+                $this->clientError(_('No status with that ID found.'),
+                                   404, $apidata['content-type']);
+            }
         }
-
     }
 
     function destroy($args, $apidata)