Merge pull request #179 from nagisa77/codex/update-notification-mechanism

Improve notification text
This commit is contained in:
Tim
2025-07-11 13:43:15 +08:00
committed by GitHub
2 changed files with 50 additions and 1 deletions

View File

@@ -105,7 +105,12 @@ public class PostService {
post.setViews(post.getViews() + 1);
post = postRepository.save(post);
if (viewer != null && !viewer.equals(post.getAuthor().getUsername())) {
notificationService.createNotification(post.getAuthor(), NotificationType.POST_VIEWED, post, null, null);
User viewerUser = userRepository.findByUsername(viewer).orElse(null);
if (viewerUser != null) {
notificationService.createNotification(post.getAuthor(), NotificationType.POST_VIEWED, post, null, null, viewerUser, null);
} else {
notificationService.createNotification(post.getAuthor(), NotificationType.POST_VIEWED, post, null, null);
}
}
return post;
}