]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
do some double-checks on favor and disfavor handlers in OStatusPlugin
authorEvan Prodromou <evan@status.net>
Sun, 21 Feb 2010 01:34:29 +0000 (20:34 -0500)
committerEvan Prodromou <evan@status.net>
Sun, 21 Feb 2010 01:34:29 +0000 (20:34 -0500)
plugins/OStatus/OStatusPlugin.php

index 5081c4d983fc1340ad60de7894ff61d8323273a4..29799b0dc1fd9bc08ad745a88ba6a9debbff1e73 100644 (file)
@@ -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;
+    }
 }