mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Fix query selecting users not accepting PMs.
This commit is contained in:
parent
ffdacba219
commit
ddd260941e
@ -114,7 +114,7 @@ class PostCreator
|
|||||||
|
|
||||||
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")
|
||||||
.joins("LEFT JOIN muted_users ON muted_users.muted_user_id = #{@user.id.to_i}")
|
.joins("LEFT JOIN muted_users ON muted_users.user_id = users.id AND muted_users.muted_user_id = #{@user.id.to_i}")
|
||||||
.where("user_options.user_id IS NOT NULL")
|
.where("user_options.user_id IS NOT NULL")
|
||||||
.where("
|
.where("
|
||||||
(user_options.user_id IN (:user_ids) AND NOT user_options.allow_private_messages) OR
|
(user_options.user_id IN (:user_ids) AND NOT user_options.allow_private_messages) OR
|
||||||
|
@ -1131,6 +1131,7 @@ describe PostCreator do
|
|||||||
|
|
||||||
context "private message to a muted user" do
|
context "private message to a muted user" do
|
||||||
let(:muted_me) { Fabricate(:evil_trout) }
|
let(:muted_me) { Fabricate(:evil_trout) }
|
||||||
|
let(:another_user) { Fabricate(:user) }
|
||||||
|
|
||||||
it 'should fail' do
|
it 'should fail' do
|
||||||
updater = UserUpdater.new(muted_me, muted_me)
|
updater = UserUpdater.new(muted_me, muted_me)
|
||||||
@ -1141,10 +1142,14 @@ describe PostCreator do
|
|||||||
title: 'this message is to someone who muted me!',
|
title: 'this message is to someone who muted me!',
|
||||||
raw: "you will have to see this even if you muted me!",
|
raw: "you will have to see this even if you muted me!",
|
||||||
archetype: Archetype.private_message,
|
archetype: Archetype.private_message,
|
||||||
target_usernames: "#{muted_me.username}"
|
target_usernames: "#{muted_me.username},#{another_user.username}"
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(pc).not_to be_valid
|
expect(pc).not_to be_valid
|
||||||
expect(pc.errors).to be_present
|
|
||||||
|
expect(pc.errors.full_messages).to contain_exactly(
|
||||||
|
I18n.t(:not_accepting_pms, username: muted_me.username)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:staff_user) { Fabricate(:admin) }
|
let(:staff_user) { Fabricate(:admin) }
|
||||||
|
Loading…
Reference in New Issue
Block a user