From f04c4b27d9281374494ae904d2aab2cab32b862a Mon Sep 17 00:00:00 2001 From: Tim <135014430+nagisa77@users.noreply.github.com> Date: Mon, 4 Aug 2025 21:29:33 +0800 Subject: [PATCH] Send email and push every five reactions --- .../com/openisle/service/ReactionService.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backend/src/main/java/com/openisle/service/ReactionService.java b/backend/src/main/java/com/openisle/service/ReactionService.java index b6cda46f5..37d62ef4d 100644 --- a/backend/src/main/java/com/openisle/service/ReactionService.java +++ b/backend/src/main/java/com/openisle/service/ReactionService.java @@ -49,6 +49,15 @@ public class ReactionService { reaction = reactionRepository.save(reaction); 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) { + String url = websiteUrl + "/messages"; + notificationService.sendCustomPush(post.getAuthor(), "你有新的互动", url); + if (post.getAuthor().getEmail() != null) { + emailSender.sendEmail(post.getAuthor().getEmail(), "你有新的互动", url); + } + } } return reaction; } @@ -73,6 +82,15 @@ public class ReactionService { reaction = reactionRepository.save(reaction); 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) { + String url = websiteUrl + "/messages"; + notificationService.sendCustomPush(comment.getAuthor(), "你有新的互动", url); + if (comment.getAuthor().getEmail() != null) { + emailSender.sendEmail(comment.getAuthor().getEmail(), "你有新的互动", url); + } + } } return reaction; }