mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE: bookmark topic button
This commit is contained in:
@ -25,7 +25,8 @@ class TopicsController < ApplicationController
|
||||
:autoclose,
|
||||
:bulk,
|
||||
:reset_new,
|
||||
:change_post_owners]
|
||||
:change_post_owners,
|
||||
:bookmark]
|
||||
|
||||
before_filter :consider_user_for_promotion, only: :show
|
||||
|
||||
@ -212,6 +213,19 @@ class TopicsController < ApplicationController
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
def bookmark
|
||||
topic = Topic.find_by(id: params[:topic_id])
|
||||
first_post = topic.ordered_posts.first
|
||||
|
||||
if params[:bookmarked] == "true"
|
||||
PostAction.act(current_user, first_post, PostActionType.types[:bookmark])
|
||||
else
|
||||
PostAction.remove_act(current_user, first_post, PostActionType.types[:bookmark])
|
||||
end
|
||||
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
def destroy
|
||||
topic = Topic.find_by(id: params[:id])
|
||||
guardian.ensure_can_delete!(topic)
|
||||
|
Reference in New Issue
Block a user