]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Realtime/RealtimePlugin.php
Merge branch 'master' into nightly
[quix0rs-gnu-social.git] / plugins / Realtime / RealtimePlugin.php
index 8087edd9df1e0f0748166f35d22d0959f9edda54..fbfb0aae306d3460878557e2004e1be6f0b902f5 100644 (file)
@@ -37,6 +37,8 @@ if (!defined('GNUSOCIAL')) { exit(1); }
  * Based on experience with the Comet and Meteor plugins,
  * this superclass extracts out some of the common functionality
  *
+ * Currently depends on Favorite plugin.
+ *
  * @category Plugin
  * @package  StatusNet
  * @author   Evan Prodromou <evan@status.net>
@@ -69,10 +71,10 @@ class RealtimePlugin extends Plugin
     /**
      * Hook for RouterInitialized event.
      *
-     * @param Net_URL_Mapper $m path-to-action mapper
+     * @param URLMapper $m path-to-action mapper
      * @return boolean hook return
      */
-    function onRouterInitialized($m)
+    public function onRouterInitialized(URLMapper $m)
     {
         $m->connect('main/channel/:channelkey/keepalive',
                     array('action' => 'keepalivechannel'),
@@ -171,8 +173,9 @@ class RealtimePlugin extends Plugin
 
         // Add to the public timeline
 
-        if ($notice->is_local == Notice::LOCAL_PUBLIC ||
-            ($notice->is_local == Notice::REMOTE && !common_config('public', 'localonly'))) {
+        $is_local = intval($notice->is_local);
+        if ($is_local === Notice::LOCAL_PUBLIC ||
+                ($is_local === Notice::REMOTE && !common_config('public', 'localonly'))) {
             $paths[] = array('public', null, null);
         }
 
@@ -318,10 +321,10 @@ class RealtimePlugin extends Plugin
         $act = new ApiAction('/dev/null');
 
         $arr = $act->twitterStatusArray($notice, true);
-        $arr['url'] = $notice->getUrl();
+        $arr['url'] = $notice->getUrl(true);
         $arr['html'] = htmlspecialchars($notice->rendered);
         $arr['source'] = htmlspecialchars($arr['source']);
-        $arr['conversation_url'] = $this->getConversationUrl($notice);
+        $arr['conversation_url'] = $notice->getConversationUrl();
 
         $profile = $notice->getProfile();
         $arr['user']['profile_url'] = $profile->profileurl;
@@ -331,12 +334,12 @@ class RealtimePlugin extends Plugin
         if (!empty($notice->repeat_of)) {
             $original = Notice::getKV('id', $notice->repeat_of);
             if ($original instanceof Notice) {
-                $arr['retweeted_status']['url'] = $original->getUrl();
+                $arr['retweeted_status']['url'] = $original->getUrl(true);
                 $arr['retweeted_status']['html'] = htmlspecialchars($original->rendered);
                 $arr['retweeted_status']['source'] = htmlspecialchars($original->source);
                 $originalProfile = $original->getProfile();
                 $arr['retweeted_status']['user']['profile_url'] = $originalProfile->profileurl;
-                $arr['retweeted_status']['conversation_url'] = $this->getConversationUrl($original);
+                $arr['retweeted_status']['conversation_url'] = $original->getConversationUrl();
             }
             unset($original);
         }
@@ -364,33 +367,6 @@ class RealtimePlugin extends Plugin
         return $tags;
     }
 
-    function getConversationUrl($notice)
-    {
-        $convurl = null;
-
-        if ($notice->hasConversation()) {
-            $conv = Conversation::getKV(
-                'id',
-                $notice->conversation
-            );
-            $convurl = $conv->uri;
-
-            if(empty($convurl)) {
-                $msg = sprintf( "Could not find Conversation ID %d to make 'in context'"
-                    . "link for Notice ID %d.",
-                    $notice->conversation,
-                    $notice->id
-                );
-
-                common_log(LOG_WARNING, $msg);
-            } else {
-                $convurl .= '#notice-' . $notice->id;
-            }
-        }
-
-        return $convurl;
-    }
-
     function _getScripts()
     {
         $urlpath = self::staticPath(str_replace('Plugin','',__CLASS__),