mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
admins can now clear flags inline
This commit is contained in:
@@ -250,6 +250,17 @@ class Post < ActiveRecord::Base
|
||||
result
|
||||
end
|
||||
|
||||
def is_flagged?
|
||||
post_actions.where('post_action_type_id in (?) and deleted_at is null', PostActionType.FlagTypes).count != 0
|
||||
end
|
||||
|
||||
def unhide!
|
||||
self.hidden = false
|
||||
self.hidden_reason_id = nil
|
||||
self.topic.update_attributes(visible: true)
|
||||
self.save
|
||||
end
|
||||
|
||||
# Update the body of a post. Will create a new version when appropriate
|
||||
def revise(updated_by, new_raw, opts={})
|
||||
|
||||
|
||||
@@ -47,10 +47,14 @@ class PostAction < ActiveRecord::Base
|
||||
user_actions
|
||||
end
|
||||
|
||||
def self.clear_flags!(post, moderator_id)
|
||||
def self.clear_flags!(post, moderator_id, action_type_id = nil)
|
||||
|
||||
# -1 is the automatic system cleary
|
||||
actions = moderator_id == -1 ? PostActionType.AutoActionFlagTypes : PostActionType.FlagTypes
|
||||
actions = if action_type_id
|
||||
[action_type_id]
|
||||
else
|
||||
moderator_id == -1 ? PostActionType.AutoActionFlagTypes : PostActionType.FlagTypes
|
||||
end
|
||||
|
||||
PostAction.exec_sql('update post_actions set deleted_at = ?, deleted_by = ?
|
||||
where post_id = ? and deleted_at is null and post_action_type_id in (?)',
|
||||
|
||||
Reference in New Issue
Block a user