mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FEATURE: don't add admins to topic allowed users if already in group
This commit is contained in:
parent
a2b72cc767
commit
4ec409f705
2 changed files with 15 additions and 1 deletions
|
@ -265,9 +265,13 @@ class PostCreator
|
|||
return unless @topic.private_message?
|
||||
|
||||
unless @topic.topic_allowed_users.where(user_id: @user.id).exists?
|
||||
unless @topic.topic_allowed_groups.where('group_id IN (
|
||||
SELECT group_id FROM group_users where user_id = ?
|
||||
)',@user.id).exists?
|
||||
@topic.topic_allowed_users.create!(user_id: @user.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def unarchive_message
|
||||
return unless @topic.private_message? && @topic.id
|
||||
|
|
|
@ -490,6 +490,16 @@ describe PostCreator do
|
|||
expect(post.topic.topic_allowed_users.where(user_id: admin.id).count).to eq(1)
|
||||
|
||||
expect(UserArchivedMessage.where(user_id: target_user2.id, topic_id: post.topic_id).count).to eq(0)
|
||||
|
||||
# if another admin replies and is already member of the group, don't add them to topic_allowed_users
|
||||
group = Fabricate(:group)
|
||||
post.topic.topic_allowed_groups.create!(group: group)
|
||||
admin2 = Fabricate(:admin)
|
||||
group.add(admin2)
|
||||
|
||||
PostCreator.create(admin2, raw: 'I am also an admin, and a mod', topic_id: post.topic_id)
|
||||
|
||||
expect(post.topic.topic_allowed_users.where(user_id: admin2.id).count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue