[PLUGIN][Favourite] Report already favoured or unfavoured

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-10 02:42:36 +00:00
parent 0c11fe413c
commit 01689edc66
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0

View File

@ -73,8 +73,11 @@ class Favourite extends FeedController
$form_add_to_favourite->handleRequest($request);
if ($form_add_to_favourite->isSubmitted()) {
\Plugin\Favourite\Favourite::favourNote(note_id: $id, actor_id: $actor_id);
if (!is_null(\Plugin\Favourite\Favourite::favourNote(note_id: $id, actor_id: $actor_id))) {
DB::flush();
} else {
throw new ClientException(_m('Note already favoured!'));
}
// Redirect user to where they came from
// Prevent open redirect
@ -129,8 +132,11 @@ class Favourite extends FeedController
$form_remove_favourite->handleRequest($request);
if ($form_remove_favourite->isSubmitted()) {
\Plugin\Favourite\Favourite::unfavourNote(note_id: $id, actor_id: $actor_id);
if (!is_null(\Plugin\Favourite\Favourite::unfavourNote(note_id: $id, actor_id: $actor_id))) {
DB::flush();
} else {
throw new ClientException(_m('Note already unfavoured!'));
}
// Redirect user to where they came from
// Prevent open redirect