]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/OStatusPlugin.php
$related must contain class names, no table names ("all" lower-case) + fixed some...
[quix0rs-gnu-social.git] / plugins / OStatus / OStatusPlugin.php
index 86d5bd733749f70abf4192ef1c0b6e37d6a24166..7c0530eb6611c2ed13da417e0eb562c7f2482c0b 100644 (file)
@@ -123,7 +123,7 @@ class OStatusPlugin extends Plugin
     /**
      * Put saved notices into the queue for pubsub distribution.
      */
-    function onStartEnqueueNotice($notice, &$transports)
+    function onStartEnqueueNotice(Notice $notice, array &$transports)
     {
         if ($notice->inScope(null)) {
             // put our transport first, in case there's any conflict (like OMB)
@@ -306,7 +306,7 @@ class OStatusPlugin extends Plugin
      * @param array &$mention in/out param: set of found mentions
      * @return boolean hook return value
      */
-    function onEndFindMentions(Profile $sender, $text, &$mentions)
+    function onEndFindMentions($sender, $text, &$mentions)
     {
         $matches = array();
 
@@ -539,7 +539,7 @@ class OStatusPlugin extends Plugin
         if ($oprofile instanceof Ostatus_profile) {
             $oprofile->processFeed($feed, 'push');
         } else {
-            common_log(LOG_DEBUG, "No ostatus profile for incoming feed $feedsub->uri");
+            common_debug("No ostatus profile for incoming feed $feedsub->uri");
         }
     }
 
@@ -867,6 +867,42 @@ class OStatusPlugin extends Plugin
         $oprofile->notifyActivity($act, $user);
     }
 
+    /**
+     * Notify remote users when their notices get favorited.
+     *
+     * @param Profile or User $profile of local user doing the faving
+     * @param Notice $notice being favored
+     * @return hook return value
+     */
+    function onEndFavorNotice(Profile $profile, Notice $notice)
+    {
+        // Only distribute local users' favor actions, remote users
+        // will have already distributed theirs.
+        if (!$profile->isLocal()) {
+            return true;
+        }
+
+        $oprofile = Ostatus_profile::getKV('profile_id', $notice->profile_id);
+        if (!$oprofile instanceof Ostatus_profile) {
+            return true;
+        }
+
+        $fav = Fave::pkeyGet(array('user_id' => $profile->id,
+                                   'notice_id' => $notice->id));
+
+        if (!$fav instanceof Fave) {
+            // That's weird.
+            // TODO: Make pkeyGet throw exception, since this is a critical failure.
+            return true;
+        }
+
+        $act = $fav->asActivity();
+
+        $oprofile->notifyActivity($act, $profile);
+
+        return true;
+    }
+
     /**
      * Notify remote user it has got a new people tag
      *   - tag verb is queued
@@ -1107,7 +1143,7 @@ class OStatusPlugin extends Plugin
         $oprofile->query(sprintf($sql, $profile->id, $profile->id));
 
         if ($oprofile->N == 0) {
-            common_log(LOG_DEBUG, "No OStatus remote subscribees for $profile->nickname");
+            common_debug("No OStatus remote subscribees for $profile->nickname");
             return true;
         }
 
@@ -1174,7 +1210,7 @@ class OStatusPlugin extends Plugin
         return true;
     }
 
-    function onPluginVersion(&$versions)
+    function onPluginVersion(array &$versions)
     {
         $versions[] = array('name' => 'OStatus',
                             'version' => GNUSOCIAL_VERSION,
@@ -1337,7 +1373,7 @@ class OStatusPlugin extends Plugin
         return true;
     }
 
-    public function onProfileDeleteRelated($profile, &$related)
+    public function onProfileDeleteRelated(Profile $profile, array &$related)
     {
         // Ostatus_profile has a 'profile_id' property, which will be used to find the object
         $related[] = 'Ostatus_profile';