feat: improve push notifications

This commit is contained in:
Tim
2025-07-30 11:53:43 +08:00
parent fe79a5481a
commit 40c919348f
5 changed files with 69 additions and 17 deletions

View File

@@ -48,9 +48,12 @@ public class ReactionService {
if (!user.getId().equals(post.getAuthor().getId())) {
notificationService.createNotification(post.getAuthor(), NotificationType.REACTION, post, null, null, user, type, null);
long count = reactionRepository.countReceived(post.getAuthor().getUsername());
if (count % 5 == 0 && post.getAuthor().getEmail() != null) {
if (count % 5 == 0) {
String url = websiteUrl + "/messages";
emailSender.sendEmail(post.getAuthor().getEmail(), "【OpenIsle】你有新的互动", url);
notificationService.sendCustomPush(post.getAuthor(), "你有新的互动", url);
if (post.getAuthor().getEmail() != null) {
emailSender.sendEmail(post.getAuthor().getEmail(), "【OpenIsle】你有新的互动", url);
}
}
}
return reaction;
@@ -76,9 +79,12 @@ public class ReactionService {
if (!user.getId().equals(comment.getAuthor().getId())) {
notificationService.createNotification(comment.getAuthor(), NotificationType.REACTION, comment.getPost(), comment, null, user, type, null);
long count = reactionRepository.countReceived(comment.getAuthor().getUsername());
if (count % 5 == 0 && comment.getAuthor().getEmail() != null) {
if (count % 5 == 0) {
String url = websiteUrl + "/messages";
emailSender.sendEmail(comment.getAuthor().getEmail(), "【OpenIsle】你有新的互动", url);
notificationService.sendCustomPush(comment.getAuthor(), "你有新的互动", url);
if (comment.getAuthor().getEmail() != null) {
emailSender.sendEmail(comment.getAuthor().getEmail(), "【OpenIsle】你有新的互动", url);
}
}
}
return reaction;