mirror of
https://github.com/discourse/discourse.git
synced 2026-08-26 13:17:20 -05:00
Add a way to flag a topic
This commit is contained in:
@@ -12,6 +12,7 @@ class PostActionsController < ApplicationController
|
||||
args = {}
|
||||
args[:message] = params[:message] if params[:message].present?
|
||||
args[:take_action] = true if guardian.is_staff? and params[:take_action] == 'true'
|
||||
args[:flag_topic] = true if params[:flag_topic]
|
||||
|
||||
post_action = PostAction.act(current_user, @post, @post_action_type_id, args)
|
||||
|
||||
@@ -63,7 +64,18 @@ class PostActionsController < ApplicationController
|
||||
|
||||
def fetch_post_from_params
|
||||
params.require(:id)
|
||||
finder = Post.where(id: params[:id])
|
||||
|
||||
post_id = if params[:flag_topic]
|
||||
begin
|
||||
Topic.find(params[:id]).posts.first.id
|
||||
rescue
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
else
|
||||
params[:id]
|
||||
end
|
||||
|
||||
finder = Post.where(id: post_id)
|
||||
|
||||
# Include deleted posts if the user is a moderator (to guardian ?)
|
||||
finder = finder.with_deleted if current_user.try(:moderator?)
|
||||
|
||||
Reference in New Issue
Block a user