do some double-checks on favor and disfavor handlers in OStatusPlugin

This commit is contained in:
Evan Prodromou 2010-02-20 20:34:29 -05:00
parent a3de4caf49
commit 0c62c68675
1 changed files with 18 additions and 5 deletions

View File

@ -365,16 +365,21 @@ class OStatusPlugin extends Plugin
* @param Notice $notice being favored * @param Notice $notice being favored
* @return hook return value * @return hook return value
*/ */
function onEndFavorNotice($profile, Notice $notice) function onEndFavorNotice(Profile $profile, Notice $notice)
{ {
if ($profile instanceof User) { $user = User::staticGet('id', $profile->id);
// @fixme upstream function should clarify its parameters
$profile = $profile->getProfile(); if (empty($user)) {
return true;
} }
$oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id); $oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
if ($oprofile) { if ($oprofile) {
$oprofile->notify($profile, ActivityVerb::FAVORITE, $notice); $oprofile->notify($profile, ActivityVerb::FAVORITE, $notice);
} }
return true;
} }
/** /**
@ -386,10 +391,18 @@ class OStatusPlugin extends Plugin
*/ */
function onEndDisfavorNotice(Profile $profile, Notice $notice) 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); $oprofile = Ostatus_profile::staticGet('profile_id', $notice->profile_id);
if ($oprofile) { if ($oprofile) {
$oprofile->notify($profile, ActivityVerb::UNFAVORITE, $notice); $oprofile->notify($profile, ActivityVerb::UNFAVORITE, $notice);
} }
}
return true;
}
} }