Skip to content

Commit

Permalink
Mark Likes on comment notifications as read when visiting a post
Browse files Browse the repository at this point in the history
  • Loading branch information
Flaburgan committed Feb 11, 2024
1 parent ae3b780 commit 71e6f20
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/services/post_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def mark_user_notifications(post_id)
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)
Expand Down Expand Up @@ -101,4 +102,11 @@ def mentions_in_comments_for_post(post_id)
.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

0 comments on commit 71e6f20

Please sign in to comment.