mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
FIX: Muted/Ignore should prevent PMs regardless of case sensitivity
This commit is contained in:
parent
81a3129ffb
commit
e8756e1a95
|
@ -96,7 +96,7 @@ class PostCreator
|
|||
end
|
||||
|
||||
if @opts[:target_usernames].present? && !skip_validations? && !@user.staff?
|
||||
names = @opts[:target_usernames].split(',')
|
||||
names = @opts[:target_usernames].split(',').flatten.map(&:downcase)
|
||||
|
||||
# Make sure max_allowed_message_recipients setting is respected
|
||||
max_allowed_message_recipients = SiteSetting.max_allowed_message_recipients
|
||||
|
@ -111,7 +111,7 @@ class PostCreator
|
|||
end
|
||||
|
||||
# Make sure none of the users have muted the creator
|
||||
users = User.where(username: names).pluck(:id, :username).to_h
|
||||
users = User.where(username_lower: names).pluck(:id, :username).to_h
|
||||
|
||||
User
|
||||
.joins("LEFT JOIN user_options ON user_options.user_id = users.id")
|
||||
|
|
|
@ -1203,7 +1203,7 @@ describe PostCreator do
|
|||
end
|
||||
|
||||
context 'private message to a user that has disabled private messages' do
|
||||
fab!(:another_user) { Fabricate(:user) }
|
||||
fab!(:another_user) { Fabricate(:user, username: 'HelloWorld') }
|
||||
|
||||
before do
|
||||
another_user.user_option.update!(allow_private_messages: false)
|
||||
|
@ -1224,6 +1224,18 @@ describe PostCreator do
|
|||
"not_accepting_pms", username: another_user.username
|
||||
))
|
||||
end
|
||||
|
||||
it 'should not be valid if the name is downcased' do
|
||||
post_creator = PostCreator.new(
|
||||
user,
|
||||
title: 'this message is to someone who muted me!',
|
||||
raw: "you will have to see this even if you muted me!",
|
||||
archetype: Archetype.private_message,
|
||||
target_usernames: "#{another_user.username.downcase}"
|
||||
)
|
||||
|
||||
expect(post_creator).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context "private message to a muted user" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user