Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark Likes on comment notifications as read when visiting a post #8442

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
SuperTux88 marked this conversation as resolved.
Show resolved Hide resolved
.update_all(unread: false) if comment_ids.any?
SuperTux88 marked this conversation as resolved.
Show resolved Hide resolved
end
end