]> 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 4cbf78e638740d41ecd3ff77516be630d5c4a615..29799b0dc1fd9bc08ad745a88ba6a9debbff1e73 100644 (file)
@@ -255,7 +255,7 @@ class OStatusPlugin extends Plugin
     {
         if ($user instanceof Profile) {
             $profile = $user;
-        } else if ($user instanceof Profile) {
+        } else if ($user instanceof User) {
             $profile = $user->getProfile();
         }
         $oprofile = Ostatus_profile::staticGet('profile_id', $other->id);
@@ -353,7 +353,7 @@ class OStatusPlugin extends Plugin
         // We have a local user subscribing to a remote profile; make the
         // magic happen!
 
-        $oprofile->notify($subscriber, ActivityVerb::FOLLOW);
+        $oprofile->notify($subscriber, ActivityVerb::FOLLOW, $oprofile);
 
         return true;
     }
@@ -365,16 +365,21 @@ class OStatusPlugin extends Plugin
      * @param Notice $notice being favored
      * @return hook return value
      */
-    function onEndFavorNotice($profile, Notice $notice)
+    function onEndFavorNotice(Profile $profile, Notice $notice)
     {
-        if ($profile instanceof User) {
-            // @fixme upstream function should clarify its parameters
-            $profile = $profile->getProfile();
+        $user = User::staticGet('id', $profile->id);
+
+        if (empty($user)) {
+            return true;
         }
+
         $oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
+
         if ($oprofile) {
             $oprofile->notify($profile, ActivityVerb::FAVORITE, $notice);
         }
+
+        return true;
     }
 
     /**
@@ -386,10 +391,18 @@ class OStatusPlugin extends Plugin
      */
     function onEndDisfavorNotice(Profile $profile, Notice $notice)
     {
+        $user = User::staticGet('id', $profile->id);
+
+        if (empty($user)) {
+            return true;
+        }
+
         $oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
+
         if ($oprofile) {
             $oprofile->notify($profile, ActivityVerb::UNFAVORITE, $notice);
         }
-    }
 
+        return true;
+    }
 }