From 7666ac34f9a4ee0096b550e4fa0408710f020eb5 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Tue, 3 Feb 2015 17:50:21 +0100 Subject: [PATCH] Revert "Notices for faves are already sent as they are notices now." This reverts commit 636d5141e994297749a78190a19b62a94f41884f. We want the salmon notifyActivity call --- plugins/OStatus/OStatusPlugin.php | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 86d5bd7337..15af953b8c 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -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 -- 2.39.2