mirror of
https://github.com/flarum/core.git
synced 2025-08-09 18:07:02 +02:00
Don't allow re-liking or re-unliking
This commit is contained in:
@@ -29,11 +29,13 @@ class PersistData
|
|||||||
throw new PermissionDeniedException;
|
throw new PermissionDeniedException;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($liked) {
|
$currentlyLiked = $post->likes()->where('user_id', $actor->id)->exists();
|
||||||
|
|
||||||
|
if ($liked && ! $currentlyLiked) {
|
||||||
$post->likes()->attach($actor->id);
|
$post->likes()->attach($actor->id);
|
||||||
|
|
||||||
$post->raise(new PostWasLiked($post, $actor));
|
$post->raise(new PostWasLiked($post, $actor));
|
||||||
} else {
|
} elseif ($currentlyLiked) {
|
||||||
$post->likes()->detach($actor->id);
|
$post->likes()->detach($actor->id);
|
||||||
|
|
||||||
$post->raise(new PostWasUnliked($post, $actor));
|
$post->raise(new PostWasUnliked($post, $actor));
|
||||||
|
Reference in New Issue
Block a user