FIX: User can't remove bookmark from a deleted post.

This commit is contained in:
Guo Xiang Tan
2017-05-19 12:25:12 +08:00
parent 870c584e25
commit 8ab9f30bbd
2 changed files with 14 additions and 1 deletions
+3 -1
View File
@@ -383,9 +383,11 @@ class PostsController < ApplicationController
PostAction.act(current_user, post, PostActionType.types[:bookmark])
else
post_action = PostAction.find_by(post_id: params[:post_id], user_id: current_user.id)
post = post_action&.post
raise Discourse::NotFound unless post_action
post = Post.with_deleted.find_by(id: post_action&.post_id)
raise Discourse::NotFound unless post
PostAction.remove_act(current_user, post, PostActionType.types[:bookmark])
end