From 41f603e34907f4d7d886f9220cdb662ccb3c1b9d Mon Sep 17 00:00:00 2001 From: tim Date: Sun, 3 Aug 2025 14:28:51 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E8=A7=84=E9=81=BF=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=81=B6=E7=8E=B0=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- .../controller/ReactionController.java | 3 ++ .../openisle/service/NotificationService.java | 32 +++++++++---------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 91cb9c662..d87d478a5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ target openisle.iml node_modules -dist \ No newline at end of file +dist +open-isle.env \ No newline at end of file diff --git a/backend/src/main/java/com/openisle/controller/ReactionController.java b/backend/src/main/java/com/openisle/controller/ReactionController.java index c762486ab..b7824a8ca 100644 --- a/backend/src/main/java/com/openisle/controller/ReactionController.java +++ b/backend/src/main/java/com/openisle/controller/ReactionController.java @@ -4,6 +4,7 @@ import com.openisle.model.Reaction; import com.openisle.model.ReactionType; import com.openisle.service.ReactionService; import com.openisle.service.LevelService; +import jakarta.transaction.Transactional; import lombok.Data; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; @@ -26,6 +27,7 @@ public class ReactionController { } @PostMapping("/posts/{postId}/reactions") + @Transactional public ResponseEntity reactToPost(@PathVariable Long postId, @RequestBody ReactionRequest req, Authentication auth) { @@ -39,6 +41,7 @@ public class ReactionController { } @PostMapping("/comments/{commentId}/reactions") + @Transactional public ResponseEntity reactToComment(@PathVariable Long commentId, @RequestBody ReactionRequest req, Authentication auth) { diff --git a/backend/src/main/java/com/openisle/service/NotificationService.java b/backend/src/main/java/com/openisle/service/NotificationService.java index 93948d5c7..ebd2d89fd 100644 --- a/backend/src/main/java/com/openisle/service/NotificationService.java +++ b/backend/src/main/java/com/openisle/service/NotificationService.java @@ -78,23 +78,23 @@ public class NotificationService { emailSender.sendEmail(user.getEmail(), "您有新的回复", pushContent + ", 点击以查看: " + url); sendCustomPush(user, pushContent, url); } else if (type == NotificationType.REACTION && comment != null) { - long count = reactionRepository.countReceived(comment.getAuthor().getUsername()); - if (count % 5 == 0) { - String url = websiteUrl + "/messages"; - sendCustomPush(comment.getAuthor(), "你有新的互动", url); - if (comment.getAuthor().getEmail() != null) { - emailSender.sendEmail(comment.getAuthor().getEmail(), "你有新的互动", "你有新的互动, 点击以查看: " + url); - } - } +// long count = reactionRepository.countReceived(comment.getAuthor().getUsername()); +// if (count % 5 == 0) { +// String url = websiteUrl + "/messages"; +// sendCustomPush(comment.getAuthor(), "你有新的互动", url); +// if (comment.getAuthor().getEmail() != null) { +// emailSender.sendEmail(comment.getAuthor().getEmail(), "你有新的互动", "你有新的互动, 点击以查看: " + url); +// } +// } } else if (type == NotificationType.REACTION && post != null) { - long count = reactionRepository.countReceived(post.getAuthor().getUsername()); - if (count % 5 == 0) { - String url = websiteUrl + "/messages"; - sendCustomPush(post.getAuthor(), "你有新的互动", url); - if (post.getAuthor().getEmail() != null) { - emailSender.sendEmail(post.getAuthor().getEmail(), "你有新的互动", "你有新的互动, 点击以查看: " + url); - } - } +// long count = reactionRepository.countReceived(post.getAuthor().getUsername()); +// if (count % 5 == 0) { +// String url = websiteUrl + "/messages"; +// sendCustomPush(post.getAuthor(), "你有新的互动", url); +// if (post.getAuthor().getEmail() != null) { +// emailSender.sendEmail(post.getAuthor().getEmail(), "你有新的互动", "你有新的互动, 点击以查看: " + url); +// } +// } } });