Skip to content

Commit 71e6f20

Browse files
committed
Mark Likes on comment notifications as read when visiting a post
1 parent ae3b780 commit 71e6f20

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/services/post_service.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def mark_user_notifications(post_id)
3333
return unless user
3434
mark_comment_reshare_like_notifications_read(post_id)
3535
mark_mention_notifications_read(post_id)
36+
mark_like_on_comment_notifications_read(post_id)
3637
end
3738

3839
def destroy(post_id, private_allowed=true)
@@ -101,4 +102,11 @@ def mentions_in_comments_for_post(post_id)
101102
.joins("INNER JOIN comments ON mentions_container_id = comments.id AND mentions_container_type = 'Comment'")
102103
.where(comments: {commentable_id: post_id, commentable_type: "Post"})
103104
end
105+
106+
def mark_like_on_comment_notifications_read(post_id)
107+
comment_ids = Comment.where(commentable_id: post_id)
108+
109+
Notification.where(recipient_id: user.id, target_type: "Comment", target_id: comment_ids, unread: true)
110+
.update_all(unread: false) if comment_ids.any?
111+
end
104112
end

0 commit comments

Comments
 (0)