mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-04-21 11:27:27 +08:00
feat: 去除多线程操作 规避400问题
This commit is contained in:
@@ -72,7 +72,7 @@ public class NotificationService {
|
|||||||
}
|
}
|
||||||
n = notificationRepository.save(n);
|
n = notificationRepository.save(n);
|
||||||
|
|
||||||
Runnable asyncTask = () -> {
|
// Runnable asyncTask = () -> {
|
||||||
if (type == NotificationType.COMMENT_REPLY && user.getEmail() != null && post != null && comment != null) {
|
if (type == NotificationType.COMMENT_REPLY && user.getEmail() != null && post != null && comment != null) {
|
||||||
String url = String.format("%s/posts/%d#comment-%d", websiteUrl, post.getId(), comment.getId());
|
String url = String.format("%s/posts/%d#comment-%d", websiteUrl, post.getId(), comment.getId());
|
||||||
emailSender.sendEmail(user.getEmail(), "有人回复了你", url);
|
emailSender.sendEmail(user.getEmail(), "有人回复了你", url);
|
||||||
@@ -96,18 +96,18 @@ public class NotificationService {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
};
|
// };
|
||||||
|
|
||||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
// if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||||
@Override
|
// @Override
|
||||||
public void afterCommit() {
|
// public void afterCommit() {
|
||||||
notificationExecutor.execute(asyncTask);
|
// notificationExecutor.execute(asyncTask);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
notificationExecutor.execute(asyncTask);
|
// notificationExecutor.execute(asyncTask);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user