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