FIX: Make deleted topic post bookmarks more resilient (#10619)

This PR ensures that new bookmarks cannot be created for deleted posts and topics, and also makes sure that if a bookmark was created and then the topic deleted that the show topic page does not error from trying to retrieve the bookmark reminder at.
This commit is contained in:
Martin Brennan
2020-09-07 14:52:14 +10:00
committed by GitHub
parent f2842490d3
commit 431bd84dec
4 changed files with 37 additions and 3 deletions

View File

@ -356,7 +356,8 @@ class TopicView
end
def first_post_bookmark_reminder_at
@topic.first_post.bookmarks.where(user: @user).pluck_first(:reminder_at)
@topic.posts.with_deleted.where(post_number: 1).first
.bookmarks.where(user: @user).pluck_first(:reminder_at)
end
MAX_PARTICIPANTS = 24