mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-09 11:39:31 +08:00
Merge pull request #368 from nagisa77/codex/fix-email-not-sent-in-tests
Send email and push notification every five reactions
This commit is contained in:
@@ -49,6 +49,15 @@ public class ReactionService {
|
|||||||
reaction = reactionRepository.save(reaction);
|
reaction = reactionRepository.save(reaction);
|
||||||
if (!user.getId().equals(post.getAuthor().getId())) {
|
if (!user.getId().equals(post.getAuthor().getId())) {
|
||||||
notificationService.createNotification(post.getAuthor(), NotificationType.REACTION, post, null, null, user, type, null);
|
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;
|
return reaction;
|
||||||
}
|
}
|
||||||
@@ -73,6 +82,15 @@ public class ReactionService {
|
|||||||
reaction = reactionRepository.save(reaction);
|
reaction = reactionRepository.save(reaction);
|
||||||
if (!user.getId().equals(comment.getAuthor().getId())) {
|
if (!user.getId().equals(comment.getAuthor().getId())) {
|
||||||
notificationService.createNotification(comment.getAuthor(), NotificationType.REACTION, comment.getPost(), comment, null, user, type, null);
|
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;
|
return reaction;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user