]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Twitter-compatible API - added source links to statuses/notices
authorzach <zach@controlyourself.ca>
Tue, 30 Sep 2008 17:53:54 +0000 (13:53 -0400)
committerzach <zach@controlyourself.ca>
Tue, 30 Sep 2008 17:53:54 +0000 (13:53 -0400)
darcs-hash:20080930175354-462f3-b49bef0e1b91ef1b94c01426c4c54900a43554d3.gz

lib/twitterapi.php

index 5bcb538f9fb8d8a8ae17fd90df4566a3d30d84bc..c8d78e1a37e52e29a16a0aed3655e16a94542351 100644 (file)
@@ -61,7 +61,7 @@ class TwitterapiAction extends Action {
                $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['source'] = $notice->source;
+               $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;
                $twitter_status['favorited'] = NULL; # XXX: Not implemented on Laconica yet.
@@ -441,4 +441,23 @@ class TwitterapiAction extends Action {
                }
        }
 
+       function source_link($source) {
+               $source_name = _($source);
+               switch ($source) {
+                case 'web':
+                case 'xmpp':
+                case 'mail':
+                case 'omb':
+                case 'api':
+                       break;
+                default:
+                       $ns = Notice_source::staticGet($source);
+                       if ($ns) {
+                               $source_name = '<a href="' . $ns->url . '">' . $ns->name . '</a>';
+                       }
+                       break;
+               }
+               return $source_name;
+       }
+
 }
\ No newline at end of file