]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Include rel-syndication link for tweets
authorStephen Paul Weber <singpolyma@singpolyma.net>
Fri, 23 Oct 2015 17:56:02 +0000 (17:56 +0000)
committerStephen Paul Weber <singpolyma@singpolyma.net>
Fri, 23 Oct 2015 17:56:02 +0000 (17:56 +0000)
As per: <http://microformats.org/wiki/rel-syndication>
This allows some services to find a post in Twitter.

plugins/TwitterBridge/TwitterBridgePlugin.php

index dd3007e309400a3b3456e7b9255034830e9f65db..72c28d4fa45eb4dfc4eefbaa1528cc357bf9055e 100644 (file)
@@ -527,6 +527,23 @@ class TwitterBridgePlugin extends Plugin
 
     public function onEndShowHeadElements(Action $action)
     {
+        if($action instanceof ShowNoticeAction) { // Showing a notice
+            $notice = Notice::getKV('id', $action->arg('notice'));
+
+            try {
+                $flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE);
+                $fuser = Foreign_user::getForeignUser($flink->foreign_id, TWITTER_SERVICE);
+            } catch (NoResultException $e) {
+                return true;
+            }
+
+            $statusId = twitter_status_id($notice);
+            if($notice instanceof Notice && $notice->isLocal() && $statusId) {
+                $tweetUrl = 'https://twitter.com/' . $fuser->nickname . '/status/' . $statusId;
+                $action->element('link', array('rel' => 'syndication', 'href' => $tweetUrl));
+            }
+        }
+
         if (!($action instanceof AttachmentAction)) {
             return true;
         }