mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-02 16:07:34 +08:00
feat: detailed reaction notifications
This commit is contained in:
@@ -16,12 +16,19 @@ public class NotificationService {
|
||||
private final UserRepository userRepository;
|
||||
|
||||
public Notification createNotification(User user, NotificationType type, Post post, Comment comment, Boolean approved) {
|
||||
return createNotification(user, type, post, comment, approved, null, null);
|
||||
}
|
||||
|
||||
public Notification createNotification(User user, NotificationType type, Post post, Comment comment, Boolean approved,
|
||||
User fromUser, ReactionType reactionType) {
|
||||
Notification n = new Notification();
|
||||
n.setUser(user);
|
||||
n.setType(type);
|
||||
n.setPost(post);
|
||||
n.setComment(comment);
|
||||
n.setApproved(approved);
|
||||
n.setFromUser(fromUser);
|
||||
n.setReactionType(reactionType);
|
||||
return notificationRepository.save(n);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ReactionService {
|
||||
reaction.setType(type);
|
||||
reaction = reactionRepository.save(reaction);
|
||||
if (!user.getId().equals(post.getAuthor().getId())) {
|
||||
notificationService.createNotification(post.getAuthor(), NotificationType.REACTION, post, null, null);
|
||||
notificationService.createNotification(post.getAuthor(), NotificationType.REACTION, post, null, null, user, type);
|
||||
}
|
||||
return reaction;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class ReactionService {
|
||||
reaction.setType(type);
|
||||
reaction = reactionRepository.save(reaction);
|
||||
if (!user.getId().equals(comment.getAuthor().getId())) {
|
||||
notificationService.createNotification(comment.getAuthor(), NotificationType.REACTION, null, comment, null);
|
||||
notificationService.createNotification(comment.getAuthor(), NotificationType.REACTION, comment.getPost(), comment, null, user, type);
|
||||
}
|
||||
return reaction;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user