]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TwitterBridge/TwitterBridgePlugin.php
Merge branch 'master' of git.gnu.io:gnu/gnu-social into mmn_fixes
[quix0rs-gnu-social.git] / plugins / TwitterBridge / TwitterBridgePlugin.php
index dd3007e309400a3b3456e7b9255034830e9f65db..0a887168539bfac69cf671bc6e47c71aad1c2293 100644 (file)
@@ -301,7 +301,7 @@ class TwitterBridgePlugin extends Plugin
             'name' => 'TwitterBridge',
             'version' => self::VERSION,
             'author' => 'Zach Copley, Julien C, Jean Baptiste Favre',
-            'homepage' => 'http://status.net/wiki/Plugin:TwitterBridge',
+            'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/TwitterBridge',
             // TRANS: Plugin description.
             'rawdescription' => _m('The Twitter "bridge" plugin allows integration ' .
                 'of a StatusNet instance with ' .
@@ -323,31 +323,6 @@ class TwitterBridgePlugin extends Plugin
         return (bool)$this->adminImportControl;
     }
 
-    /**
-     * When the site is set to ssl=sometimes mode, we should make sure our
-     * various auth-related pages are on SSL to keep things looking happy.
-     * Although we're not submitting passwords directly, we do link out to
-     * an authentication source and it's a lot happier if we've got some
-     * protection against MitM.
-     *
-     * @param string $action name
-     * @param boolean $ssl outval to force SSL
-     * @return mixed hook return value
-     */
-    function onSensitiveAction($action, &$ssl)
-    {
-        $sensitive = array('twitteradminpanel',
-                           'twittersettings',
-                           'twitterauthorization',
-                           'twitterlogin');
-        if (in_array($action, $sensitive)) {
-            $ssl = true;
-            return false;
-        } else {
-            return true;
-        }
-    }
-
     /**
      * Database schema setup
      *
@@ -527,6 +502,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;
         }