]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/twitterapi.php
Added the new pinghandler to the stopdaemons script and improved the behaviour and...
[quix0rs-gnu-social.git] / lib / twitterapi.php
index da8b8b1e5b4f3e83625d020907908c6b87ee55e0..1de169a0b139255a8b7a02abaf5f0b2d3d1bfd17 100644 (file)
@@ -24,11 +24,33 @@ class TwitterapiAction extends Action
 
     var $auth_user;
 
+    /**
+     * Initialization.
+     *
+     * @param array $args Web and URL arguments
+     *
+     * @return boolean false if user doesn't exist
+     */
+
+    function prepare($args)
+    {
+        parent::prepare($args);
+        return true;
+    }
+
+    /**
+     * Handle a request
+     *
+     * @param array $args Arguments from $_REQUEST
+     *
+     * @return void
+     */
+
     function handle($args)
     {
         parent::handle($args);
     }
-    
+
     function twitter_user_array($profile, $get_notice=false)
     {
 
@@ -43,7 +65,7 @@ class TwitterapiAction extends Action
 
         $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
 
-        $twitter_user['profile_image_url'] = ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE);
+        $twitter_user['profile_image_url'] = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE);
         $twitter_user['protected'] = 'false'; # not supported by Laconica yet
         $twitter_user['url'] = ($profile->homepage) ? $profile->homepage : null;
 
@@ -60,20 +82,34 @@ class TwitterapiAction extends Action
 
     function twitter_status_array($notice, $include_user=true)
     {
-
         $profile = $notice->getProfile();
 
         $twitter_status = array();
         $twitter_status['text'] = $notice->content;
         $twitter_status['truncated'] = 'false'; # Not possible on Laconica
         $twitter_status['created_at'] = $this->date_twitter($notice->created);
-        $twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ? intval($notice->reply_to) : null;
+        $twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ?
+            intval($notice->reply_to) : null;
         $twitter_status['source'] = $this->source_link($notice->source);
         $twitter_status['id'] = intval($notice->id);
-        $twitter_status['in_reply_to_user_id'] = ($notice->reply_to) ? $this->replier_by_reply(intval($notice->reply_to)) : null;
+
+        $replier_profile = null;
+
+        if ($notice->reply_to) {
+            $reply = Notice::staticGet(intval($notice->reply_to));
+            if ($reply) {
+                $replier_profile = $reply->getProfile();
+            }
+        }
+
+        $twitter_status['in_reply_to_user_id'] =
+            ($replier_profile) ? intval($replier_profile->id) : null;
+        $twitter_status['in_reply_to_screen_name'] =
+            ($replier_profile) ? $replier_profile->nickname : null;
 
         if (isset($this->auth_user)) {
-            $twitter_status['favorited'] = ($this->auth_user->hasFave($notice)) ? 'true' : 'false';
+            $twitter_status['favorited'] =
+                ($this->auth_user->hasFave($notice)) ? 'true' : 'false';
         } else {
             $twitter_status['favorited'] = 'false';
         }
@@ -137,7 +173,6 @@ class TwitterapiAction extends Action
 
     function twitter_dmsg_array($message)
     {
-
         $twitter_dm = array();
 
         $from_profile = $message->getFrom();
@@ -387,22 +422,6 @@ class TwitterapiAction extends Action
         return date("D M d G:i:s O Y", $t);
     }
 
-    function replier_by_reply($reply_id)
-    {
-        $notice = Notice::staticGet($reply_id);
-        if ($notice) {
-            $profile = $notice->getProfile();
-            if ($profile) {
-                return intval($profile->id);
-            } else {
-                common_debug('Can\'t find a profile for notice: ' . $notice->id, __FILE__);
-            }
-        } else {
-            common_debug("Can't get notice: $reply_id", __FILE__);
-        }
-        return null;
-    }
-
     // XXX: Candidate for a general utility method somewhere?
     function count_subscriptions($profile)
     {