mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: Allow user to remove bookmark from posts as long as bookmark is present.
https://meta.discourse.org/t/bookmark-issue-when-access-to-topic-is-lost-pms/51993
This commit is contained in:
@ -377,17 +377,19 @@ class PostsController < ApplicationController
|
||||
end
|
||||
|
||||
def bookmark
|
||||
post = find_post_from_params
|
||||
|
||||
if params[:bookmarked] == "true"
|
||||
post = find_post_from_params
|
||||
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::InvalidParameters unless post_action
|
||||
|
||||
PostAction.remove_act(current_user, post, PostActionType.types[:bookmark])
|
||||
end
|
||||
|
||||
tu = TopicUser.get(post.topic, current_user)
|
||||
|
||||
render_json_dump(topic_bookmarked: tu.try(:bookmarked))
|
||||
topic_user = TopicUser.get(post.topic, current_user)
|
||||
render_json_dump(topic_bookmarked: topic_user.try(:bookmarked))
|
||||
end
|
||||
|
||||
def wiki
|
||||
|
Reference in New Issue
Block a user