mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 12:05:31 +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
|
end
|
||||||
|
|
||||||
if @opts[:target_usernames].present? && !skip_validations? && !@user.staff?
|
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
|
# Make sure max_allowed_message_recipients setting is respected
|
||||||
max_allowed_message_recipients = SiteSetting.max_allowed_message_recipients
|
max_allowed_message_recipients = SiteSetting.max_allowed_message_recipients
|
||||||
|
@ -111,7 +111,7 @@ class PostCreator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make sure none of the users have muted the creator
|
# 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
|
User
|
||||||
.joins("LEFT JOIN user_options ON user_options.user_id = users.id")
|
.joins("LEFT JOIN user_options ON user_options.user_id = users.id")
|
||||||
|
|
|
@ -1203,7 +1203,7 @@ describe PostCreator do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'private message to a user that has disabled private messages' do
|
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
|
before do
|
||||||
another_user.user_option.update!(allow_private_messages: false)
|
another_user.user_option.update!(allow_private_messages: false)
|
||||||
|
@ -1224,6 +1224,18 @@ describe PostCreator do
|
||||||
"not_accepting_pms", username: another_user.username
|
"not_accepting_pms", username: another_user.username
|
||||||
))
|
))
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "private message to a muted user" do
|
context "private message to a muted user" do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user