]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/OStatusPlugin.php
do some double-checks on favor and disfavor handlers in OStatusPlugin
[quix0rs-gnu-social.git] / plugins / OStatus / OStatusPlugin.php
index 98e048c14c0c2d2c3e106621b03c636eafaca285..29799b0dc1fd9bc08ad745a88ba6a9debbff1e73 100644 (file)
@@ -358,59 +358,51 @@ class OStatusPlugin extends Plugin
         return true;
     }
 
-    function onEndFavor($profile, $notice)
+    /**
+     * 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)
     {
-        // is the favorer a local user?
-
         $user = User::staticGet('id', $profile->id);
 
         if (empty($user)) {
             return true;
         }
 
-        // is the author an OStatus remote user?
-
         $oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
 
-        if (empty($oprofile)) {
-            return true;
+        if ($oprofile) {
+            $oprofile->notify($profile, ActivityVerb::FAVORITE, $notice);
         }
 
-        // Local user faved an Ostatus profile's notice; notify them!
-
-        $obj = ActivityObject::fromNotice($notice);
-
-        $oprofile->notify($profile,
-                          ActivityVerb::FAVORITE,
-                          $obj->asString());
         return true;
     }
 
-    function onEndDisfavor($profile, $notice)
+    /**
+     * Notify remote users when their notices get de-favorited.
+     *
+     * @param Profile or User $profile of local user doing the de-faving
+     * @param Notice $notice being favored
+     * @return hook return value
+     */
+    function onEndDisfavorNotice(Profile $profile, Notice $notice)
     {
-        // is the favorer a local user?
-
         $user = User::staticGet('id', $profile->id);
 
         if (empty($user)) {
             return true;
         }
 
-        // is the author an OStatus remote user?
-
         $oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
 
-        if (empty($oprofile)) {
-            return true;
+        if ($oprofile) {
+            $oprofile->notify($profile, ActivityVerb::UNFAVORITE, $notice);
         }
 
-        // Local user faved an Ostatus profile's notice; notify them!
-
-        $obj = ActivityObject::fromNotice($notice);
-
-        $oprofile->notify($profile,
-                          ActivityVerb::UNFAVORITE,
-                          $obj->asString());
         return true;
     }
 }