mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FEATURE: allow moderators to see offical warnings
This commit is contained in:
parent
36e3e53798
commit
50fce0998f
2 changed files with 11 additions and 1 deletions
|
@ -254,9 +254,13 @@ class Topic < ActiveRecord::Base
|
||||||
.exists?
|
.exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_official_warning?
|
||||||
|
subtype == TopicSubtype.moderator_warning
|
||||||
|
end
|
||||||
|
|
||||||
# all users (in groups or directly targetted) that are going to get the pm
|
# all users (in groups or directly targetted) that are going to get the pm
|
||||||
def all_allowed_users
|
def all_allowed_users
|
||||||
moderators_sql = " UNION #{User.moderators.to_sql}" if private_message? && has_flags?
|
moderators_sql = " UNION #{User.moderators.to_sql}" if private_message? && (has_flags? || is_official_warning?)
|
||||||
User.from("(#{allowed_users.to_sql} UNION #{allowed_group_users.to_sql}#{moderators_sql}) as users")
|
User.from("(#{allowed_users.to_sql} UNION #{allowed_group_users.to_sql}#{moderators_sql}) as users")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1367,6 +1367,12 @@ describe Topic do
|
||||||
expect(topic.all_allowed_users).to include moderator
|
expect(topic.all_allowed_users).to include moderator
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'includes moderators if offical warning' do
|
||||||
|
topic.stubs(:subtype).returns(TopicSubtype.moderator_warning)
|
||||||
|
topic.stubs(:private_message?).returns(true)
|
||||||
|
expect(topic.all_allowed_users).to include moderator
|
||||||
|
end
|
||||||
|
|
||||||
it 'does not include moderators if pm without flags' do
|
it 'does not include moderators if pm without flags' do
|
||||||
topic.stubs(:private_message?).returns(true)
|
topic.stubs(:private_message?).returns(true)
|
||||||
expect(topic.all_allowed_users).not_to include moderator
|
expect(topic.all_allowed_users).not_to include moderator
|
||||||
|
|
Loading…
Reference in a new issue