mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-07 10:37:33 +08:00
bugfix: 规避后台偶现失败的问题
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ target
|
|||||||
openisle.iml
|
openisle.iml
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
open-isle.env
|
||||||
@@ -4,6 +4,7 @@ import com.openisle.model.Reaction;
|
|||||||
import com.openisle.model.ReactionType;
|
import com.openisle.model.ReactionType;
|
||||||
import com.openisle.service.ReactionService;
|
import com.openisle.service.ReactionService;
|
||||||
import com.openisle.service.LevelService;
|
import com.openisle.service.LevelService;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -26,6 +27,7 @@ public class ReactionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/posts/{postId}/reactions")
|
@PostMapping("/posts/{postId}/reactions")
|
||||||
|
@Transactional
|
||||||
public ResponseEntity<ReactionDto> reactToPost(@PathVariable Long postId,
|
public ResponseEntity<ReactionDto> reactToPost(@PathVariable Long postId,
|
||||||
@RequestBody ReactionRequest req,
|
@RequestBody ReactionRequest req,
|
||||||
Authentication auth) {
|
Authentication auth) {
|
||||||
@@ -39,6 +41,7 @@ public class ReactionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/comments/{commentId}/reactions")
|
@PostMapping("/comments/{commentId}/reactions")
|
||||||
|
@Transactional
|
||||||
public ResponseEntity<ReactionDto> reactToComment(@PathVariable Long commentId,
|
public ResponseEntity<ReactionDto> reactToComment(@PathVariable Long commentId,
|
||||||
@RequestBody ReactionRequest req,
|
@RequestBody ReactionRequest req,
|
||||||
Authentication auth) {
|
Authentication auth) {
|
||||||
|
|||||||
@@ -78,23 +78,23 @@ public class NotificationService {
|
|||||||
emailSender.sendEmail(user.getEmail(), "您有新的回复", pushContent + ", 点击以查看: " + url);
|
emailSender.sendEmail(user.getEmail(), "您有新的回复", pushContent + ", 点击以查看: " + url);
|
||||||
sendCustomPush(user, pushContent, url);
|
sendCustomPush(user, pushContent, url);
|
||||||
} else if (type == NotificationType.REACTION && comment != null) {
|
} else if (type == NotificationType.REACTION && comment != null) {
|
||||||
long count = reactionRepository.countReceived(comment.getAuthor().getUsername());
|
// long count = reactionRepository.countReceived(comment.getAuthor().getUsername());
|
||||||
if (count % 5 == 0) {
|
// if (count % 5 == 0) {
|
||||||
String url = websiteUrl + "/messages";
|
// String url = websiteUrl + "/messages";
|
||||||
sendCustomPush(comment.getAuthor(), "你有新的互动", url);
|
// sendCustomPush(comment.getAuthor(), "你有新的互动", url);
|
||||||
if (comment.getAuthor().getEmail() != null) {
|
// if (comment.getAuthor().getEmail() != null) {
|
||||||
emailSender.sendEmail(comment.getAuthor().getEmail(), "你有新的互动", "你有新的互动, 点击以查看: " + url);
|
// emailSender.sendEmail(comment.getAuthor().getEmail(), "你有新的互动", "你有新的互动, 点击以查看: " + url);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else if (type == NotificationType.REACTION && post != null) {
|
} else if (type == NotificationType.REACTION && post != null) {
|
||||||
long count = reactionRepository.countReceived(post.getAuthor().getUsername());
|
// long count = reactionRepository.countReceived(post.getAuthor().getUsername());
|
||||||
if (count % 5 == 0) {
|
// if (count % 5 == 0) {
|
||||||
String url = websiteUrl + "/messages";
|
// String url = websiteUrl + "/messages";
|
||||||
sendCustomPush(post.getAuthor(), "你有新的互动", url);
|
// sendCustomPush(post.getAuthor(), "你有新的互动", url);
|
||||||
if (post.getAuthor().getEmail() != null) {
|
// if (post.getAuthor().getEmail() != null) {
|
||||||
emailSender.sendEmail(post.getAuthor().getEmail(), "你有新的互动", "你有新的互动, 点击以查看: " + url);
|
// emailSender.sendEmail(post.getAuthor().getEmail(), "你有新的互动", "你有新的互动, 点击以查看: " + url);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user