]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/twitapistatuses.php
Merge remote branch 'statusnet/0.8.x' into 0.9.x
[quix0rs-gnu-social.git] / actions / twitapistatuses.php
index e3d366ecc8dddf7f4914faafaa935d1cbfeeea86..c589bd9b1ca332dd4c9b0758747044bcab25c75b 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,6 +136,11 @@ class TwitapistatusesAction extends TwitterapiAction
 
     }
 
+    function home_timeline($args, $apidata)
+    {
+        call_user_func(array($this, 'friends_timeline'), $args, $apidata);
+    }
+
     function user_timeline($args, $apidata)
     {
         parent::handle($args);
@@ -242,14 +247,15 @@ class TwitapistatusesAction extends TwitterapiAction
 
             $status_shortened = common_shorten_links($status);
 
-            if (mb_strlen($status_shortened) > 140) {
+            if (Notice::contentTooLong($status_shortened)) {
 
                 // XXX: Twitter truncates anything over 140, flags the status
                 // as "truncated." Sending this error may screw up some clients
                 // that assume Twitter will truncate for them.    Should we just
                 // truncate too? -- Zach
-                $this->clientError(_('That\'s too long. Max notice size is 140 chars.'),
-                    $code = 406, $apidata['content-type']);
+                $this->clientError(sprintf(_('That\'s too long. Max notice size is %d chars.'),
+                                           Notice::maxContent()),
+                                   $code = 406, $apidata['content-type']);
                 return;
             }
         }
@@ -291,11 +297,6 @@ class TwitapistatusesAction extends TwitterapiAction
                 html_entity_decode($status, ENT_NOQUOTES, 'UTF-8'),
                     $source, 1, $reply_to);
 
-            if (is_string($notice)) {
-                $this->serverError($notice);
-                return;
-            }
-
             common_broadcast_notice($notice);
             $apidata['api_arg'] = $notice->id;
         }
@@ -455,7 +456,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)
@@ -467,7 +469,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)
@@ -476,7 +479,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);
@@ -532,26 +535,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;