A platform for community discussion. Free, open, simple.
FIX: Muted/Ignore should prevent PMs regardless of case sensitivity
Robin Warde8756e1a955a
diff --git a/lib/post_creator.rb b/lib/post_creator.rbindex c3b9556df21..6a9e4ca8735 100644--- a/lib/post_creator.rb+++ b/lib/post_creator.rb@@ -96,7 +96,7 @@ class PostCreatorendif @opts[:target_usernames].present? && !skip_validations? && [email protected]?- names = @opts[:target_usernames].split(',')+ names = @opts[:target_usernames].split(',').flatten.map(&:downcase)# Make sure max_allowed_message_recipients setting is respectedmax_allowed_message_recipients = SiteSetting.max_allowed_message_recipients@@ -111,7 +111,7 @@ class PostCreatorend# 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_hUser.joins("LEFT JOIN user_options ON user_options.user_id = users.id")diff --git a/spec/components/post_creator_spec.rb b/spec/components/post_creator_spec.rbindex 59369598049..27fba7c4861 100644--- a/spec/components/post_creator_spec.rb+++ b/spec/components/post_creator_spec.rb@@ -1203,7 +1203,7 @@ describe PostCreator doendcontext 'private message to a user that has disabled private messages' do- fab!(:another_user) { Fabricate(:user) }+ fab!(:another_user) { Fabricate(:user, username: 'HelloWorld') }before doanother_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+ endendcontext "private message to a muted user" do