Mark Likes on comment notifications as read when visiting a post

This commit is contained in:
flaburgan 2024-02-11 18:35:03 +01:00
parent ae3b7804f0
commit 71e6f20740

View file

@ -33,6 +33,7 @@ class PostService
return unless user
mark_comment_reshare_like_notifications_read(post_id)
mark_mention_notifications_read(post_id)
mark_like_on_comment_notifications_read(post_id)
end
def destroy(post_id, private_allowed=true)
@ -101,4 +102,11 @@ class PostService
.joins("INNER JOIN comments ON mentions_container_id = comments.id AND mentions_container_type = 'Comment'")
.where(comments: {commentable_id: post_id, commentable_type: "Post"})
end
def mark_like_on_comment_notifications_read(post_id)
comment_ids = Comment.where(commentable_id: post_id)
Notification.where(recipient_id: user.id, target_type: "Comment", target_id: comment_ids, unread: true)
.update_all(unread: false) if comment_ids.any?
end
end