mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-08 03:37:28 +08:00
Allow multiple reactions
This commit is contained in:
@@ -28,11 +28,6 @@ public class ReactionService {
|
|||||||
.orElseThrow(() -> new IllegalArgumentException("User not found"));
|
.orElseThrow(() -> new IllegalArgumentException("User not found"));
|
||||||
Post post = postRepository.findById(postId)
|
Post post = postRepository.findById(postId)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("Post not found"));
|
.orElseThrow(() -> new IllegalArgumentException("Post not found"));
|
||||||
java.util.Optional<Reaction> existing =
|
|
||||||
reactionRepository.findByUserAndPostAndType(user, post, type);
|
|
||||||
if (existing.isPresent()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Reaction reaction = new Reaction();
|
Reaction reaction = new Reaction();
|
||||||
reaction.setUser(user);
|
reaction.setUser(user);
|
||||||
reaction.setPost(post);
|
reaction.setPost(post);
|
||||||
@@ -49,11 +44,6 @@ public class ReactionService {
|
|||||||
.orElseThrow(() -> new IllegalArgumentException("User not found"));
|
.orElseThrow(() -> new IllegalArgumentException("User not found"));
|
||||||
Comment comment = commentRepository.findById(commentId)
|
Comment comment = commentRepository.findById(commentId)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("Comment not found"));
|
.orElseThrow(() -> new IllegalArgumentException("Comment not found"));
|
||||||
java.util.Optional<Reaction> existing =
|
|
||||||
reactionRepository.findByUserAndCommentAndType(user, comment, type);
|
|
||||||
if (existing.isPresent()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Reaction reaction = new Reaction();
|
Reaction reaction = new Reaction();
|
||||||
reaction.setUser(user);
|
reaction.setUser(user);
|
||||||
reaction.setComment(comment);
|
reaction.setComment(comment);
|
||||||
|
|||||||
Reference in New Issue
Block a user