mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 14:08:32 +08:00
FEATURE: allow moderators to see flagged private messages
This commit is contained in:
@ -231,10 +231,19 @@ class Topic < ActiveRecord::Base
|
||||
posts.order('score desc').limit(1).first
|
||||
end
|
||||
|
||||
def has_flags?
|
||||
FlagQuery.flagged_post_actions("active")
|
||||
.where("topics.id" => id)
|
||||
.exists?
|
||||
end
|
||||
|
||||
# all users (in groups or directly targetted) that are going to get the pm
|
||||
def all_allowed_users
|
||||
# TODO we should probably change this from 3 queries to 1
|
||||
User.where('id in (?)', allowed_users.select('users.id').to_a + allowed_group_users.select('users.id').to_a)
|
||||
# TODO we should probably change this to 1 query
|
||||
allowed_user_ids = allowed_users.select('users.id').to_a
|
||||
allowed_group_user_ids = allowed_group_users.select('users.id').to_a
|
||||
allowed_staff_ids = private_message? && has_flags? ? User.where(moderator: true).pluck(:id).to_a : []
|
||||
User.where('id IN (?)', allowed_user_ids + allowed_group_user_ids + allowed_staff_ids)
|
||||
end
|
||||
|
||||
# Additional rate limits on topics: per day and private messages per day
|
||||
|
Reference in New Issue
Block a user