[PLUGIN][Favourite] Notify when actor favours a note

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-10 04:02:27 +00:00
parent 60d31e097e
commit 0ee4cc7709
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0

View File

@ -58,6 +58,8 @@ class Favourite extends NoteHandlerPlugin
'source' => $source, 'source' => $source,
]); ]);
DB::persist($act); DB::persist($act);
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $act, [], "{$actor->getNickname()} favoured note {$note_id}"]);
} }
return $act ?? null; return $act ?? null;
} }
@ -76,6 +78,8 @@ class Favourite extends NoteHandlerPlugin
'source' => $source, 'source' => $source,
]); ]);
DB::persist($act); DB::persist($act);
Event::handle('NewNotification', [$actor = Actor::getById($actor_id), $act, [], "{$actor->getNickname()} unfavoured note {$note_id}"]);
} }
return $act ?? null; return $act ?? null;
} }
@ -84,11 +88,10 @@ class Favourite extends NoteHandlerPlugin
* HTML rendering event that adds the favourite form as a note * HTML rendering event that adds the favourite form as a note
* action, if a user is logged in * action, if a user is logged in
* *
* @param Request $request
* @param Note $note
* @param array $actions
* @return bool Event hook * @return bool Event hook
* @throws NoSuchNoteException
* @throws RedirectException
*
* @throws InvalidFormException
*/ */
public function onAddNoteActions(Request $request, Note $note, array &$actions): bool public function onAddNoteActions(Request $request, Note $note, array &$actions): bool
{ {