]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/twitapistatuses.php
Revert "Added bit about being incompatible with file attachment virtual server"
[quix0rs-gnu-social.git] / actions / twitapistatuses.php
index ec5d378f04a9aa5dff68aea7891962f09e1db683..b0d3e584ba0e202570049a3d0343b9125eaa0a6c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
@@ -136,62 +136,9 @@ class TwitapistatusesAction extends TwitterapiAction
 
     }
 
-    function group_timeline($args, $apidata)
+    function home_timeline($args, $apidata)
     {
-        parent::handle($args);
-
-        $this->auth_user = $apidata['user'];
-        $group = $this->get_group($apidata['api_arg'], $apidata);
-
-        if (empty($group)) {
-            $this->clientError('Not Found', 404, $apidata['content-type']);
-            return;
-        }
-
-        $sitename   = common_config('site', 'name');
-        $title      = sprintf(_("%s timeline"), $group->nickname);
-        $taguribase = common_config('integration', 'taguri');
-        $id         = "tag:$taguribase:GroupTimeline:".$group->id;
-        $link       = common_local_url('showstream',
-            array('nickname' => $group->nickname));
-        $subtitle   = sprintf(_('Updates from %1$s on %2$s!'),
-            $group->nickname, $sitename);
-
-        $page     = (int)$this->arg('page', 1);
-        $count    = (int)$this->arg('count', 20);
-        $max_id   = (int)$this->arg('max_id', 0);
-        $since_id = (int)$this->arg('since_id', 0);
-        $since    = $this->arg('since');
-
-        $notice = $group->getNotices(($page-1)*$count,
-            $count, $since_id, $max_id, $since);
-
-        switch($apidata['content-type']) {
-         case 'xml':
-            $this->show_xml_timeline($notice);
-            break;
-         case 'rss':
-            $this->show_rss_timeline($notice, $title, $link,
-                $subtitle, $suplink);
-            break;
-         case 'atom':
-            if (isset($apidata['api_arg'])) {
-                $selfuri = common_root_url() .
-                    'api/statuses/group_timeline/' .
-                        $apidata['api_arg'] . '.atom';
-            } else {
-                $selfuri = common_root_url() .
-                 'api/statuses/group_timeline.atom';
-            }
-            $this->show_atom_timeline($notice, $title, $id, $link,
-                $subtitle, $suplink, $selfuri);
-            break;
-         case 'json':
-            $this->show_json_timeline($notice);
-            break;
-         default:
-            $this->clientError(_('API method not found!'), $code = 404);
-        }
+        call_user_func(array($this, 'friends_timeline'), $args, $apidata);
     }
 
     function user_timeline($args, $apidata)
@@ -289,11 +236,8 @@ class TwitapistatusesAction extends TwitterapiAction
         }
 
         if (empty($status)) {
-
-            // XXX: Note: In this case, Twitter simply returns '200 OK'
-            // No error is given, but the status is not posted to the
-            // user's timeline.     Seems bad.     Shouldn't we throw an
-            // errror? -- Zach
+            $this->clientError(_('Client must provide a \'status\' parameter with a value.'),
+                $code = 403, $apidata['content-type']);
             return;
 
         } else {
@@ -350,7 +294,7 @@ class TwitapistatusesAction extends TwitterapiAction
                     $source, 1, $reply_to);
 
             if (is_string($notice)) {
-                $this->serverError($notice);
+                $this->serverError($notice, 500, $apidata['content-type']);
                 return;
             }
 
@@ -507,7 +451,8 @@ class TwitapistatusesAction extends TwitterapiAction
     function friends($args, $apidata)
     {
         parent::handle($args);
-        return $this->subscriptions($apidata, 'subscribed', 'subscriber');
+        $includeStatuses= !(array_key_exists('lite', $args) and $args['lite']);
+        return $this->subscriptions($apidata, 'subscribed', 'subscriber', false, $includeStatuses);
     }
 
     function friendsIDs($args, $apidata)
@@ -519,7 +464,8 @@ class TwitapistatusesAction extends TwitterapiAction
     function followers($args, $apidata)
     {
         parent::handle($args);
-        return $this->subscriptions($apidata, 'subscriber', 'subscribed');
+        $includeStatuses= !(array_key_exists('lite', $args) and $args['lite']);
+        return $this->subscriptions($apidata, 'subscriber', 'subscribed', false, $includeStatuses);
     }
 
     function followersIDs($args, $apidata)
@@ -528,7 +474,7 @@ class TwitapistatusesAction extends TwitterapiAction
         return $this->subscriptions($apidata, 'subscriber', 'subscribed', true);
     }
 
-    function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs=false)
+    function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs=false, $includeStatuses=true)
     {
         $this->auth_user = $apidata['user'];
         $user = $this->get_user($apidata['api_arg'], $apidata);
@@ -584,26 +530,26 @@ class TwitapistatusesAction extends TwitterapiAction
         if ($onlyIDs) {
             $this->showIDs($others, $type);
         } else {
-            $this->show_profiles($others, $type);
+            $this->show_profiles($others, $type, $includeStatuses);
         }
 
         $this->end_document($type);
     }
 
-    function show_profiles($profiles, $type)
+    function show_profiles($profiles, $type, $includeStatuses)
     {
         switch ($type) {
         case 'xml':
             $this->elementStart('users', array('type' => 'array'));
             foreach ($profiles as $profile) {
-                $this->show_profile($profile);
+                $this->show_profile($profile,$type,null,$includeStatuses);
             }
             $this->elementEnd('users');
             break;
         case 'json':
             $arrays = array();
             foreach ($profiles as $profile) {
-                $arrays[] = $this->twitter_user_array($profile, true);
+                $arrays[] = $this->twitter_user_array($profile, $includeStatuses);
             }
             print json_encode($arrays);
             break;