@@ -233,6 +256,27 @@ export default {
}
}
})
+ } else if (n.type === 'POST_VIEWED') {
+ notifications.value.push({
+ ...n,
+ src: n.fromUser ? n.fromUser.avatar : null,
+ icon: n.fromUser ? undefined : iconMap[n.type],
+ iconClick: () => {
+ if (n.fromUser) {
+ markRead(n.id)
+ router.push(`/users/${n.fromUser.id}`)
+ }
+ }
+ })
+ } else if (n.type === 'POST_UPDATED') {
+ notifications.value.push({
+ ...n,
+ src: n.comment.author.avatar,
+ iconClick: () => {
+ markRead(n.id)
+ router.push(`/users/${n.comment.author.id}`)
+ }
+ })
} else if (n.type === 'USER_FOLLOWED' || n.type === 'USER_UNFOLLOWED') {
notifications.value.push({
...n,
diff --git a/src/main/java/com/openisle/service/PostService.java b/src/main/java/com/openisle/service/PostService.java
index 38528b2ce..16f49f55e 100644
--- a/src/main/java/com/openisle/service/PostService.java
+++ b/src/main/java/com/openisle/service/PostService.java
@@ -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;
}