From 0ee4cc77095fd82d99c7b1a432f555be3e4c2a13 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Fri, 10 Dec 2021 04:02:27 +0000 Subject: [PATCH] [PLUGIN][Favourite] Notify when actor favours a note --- plugins/Favourite/Favourite.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/Favourite/Favourite.php b/plugins/Favourite/Favourite.php index 565bafd3f9..f8579b62ff 100644 --- a/plugins/Favourite/Favourite.php +++ b/plugins/Favourite/Favourite.php @@ -58,6 +58,8 @@ class Favourite extends NoteHandlerPlugin 'source' => $source, ]); DB::persist($act); + + Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $act, [], "{$actor->getNickname()} favoured note {$note_id}"]); } return $act ?? null; } @@ -76,6 +78,8 @@ class Favourite extends NoteHandlerPlugin 'source' => $source, ]); DB::persist($act); + + Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $act, [], "{$actor->getNickname()} unfavoured note {$note_id}"]); } return $act ?? null; } @@ -84,11 +88,10 @@ class Favourite extends NoteHandlerPlugin * HTML rendering event that adds the favourite form as a note * action, if a user is logged in * + * @param Request $request + * @param Note $note + * @param array $actions * @return bool Event hook - * @throws NoSuchNoteException - * @throws RedirectException - * - * @throws InvalidFormException */ public function onAddNoteActions(Request $request, Note $note, array &$actions): bool {