mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: admins could never remove self from messages
This commit is contained in:
parent
6ddd8d9166
commit
4b449914b8
2 changed files with 16 additions and 1 deletions
|
@ -698,6 +698,9 @@ SQL
|
||||||
topic_user = topic_allowed_users.find_by(user_id: user.id)
|
topic_user = topic_allowed_users.find_by(user_id: user.id)
|
||||||
if topic_user
|
if topic_user
|
||||||
topic_user.destroy
|
topic_user.destroy
|
||||||
|
# we can not remove ourselves cause then we will end up adding
|
||||||
|
# ourselves in add_small_action
|
||||||
|
removed_by = Discourse.system_user if user.id == removed_by.id
|
||||||
add_small_action(removed_by, "removed_user", user.username)
|
add_small_action(removed_by, "removed_user", user.username)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -1134,9 +1134,21 @@ describe TopicsController do
|
||||||
xhr :put, :make_banner, topic_id: topic.id
|
xhr :put, :make_banner, topic_id: topic.id
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'remove_allowed_user' do
|
||||||
|
it 'admin can be removed from a pm' do
|
||||||
|
|
||||||
|
admin = log_in :admin
|
||||||
|
user = Fabricate(:user)
|
||||||
|
pm = create_post(user: user, archetype: 'private_message', target_usernames: [user.username, admin.username])
|
||||||
|
|
||||||
|
xhr :put, :remove_allowed_user, topic_id: pm.topic_id, username: admin.username
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
expect(TopicAllowedUser.where(topic_id: pm.topic_id, user_id: admin.id).first).to eq(nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'remove_banner' do
|
describe 'remove_banner' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue