FIX: do not show send pm prompt when user cant pm (#25912)

Prior to this fix even when the user was not part of a group allowing sending pm we would show the prompt: "You've replied to ... X times, did you know you could send them a personal message instead?"
This commit is contained in:
Joffrey JAFFEUX 2024-02-27 11:54:05 +01:00 committed by GitHub
parent 3736d66f17
commit 64e8ad170e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -181,6 +181,7 @@ class ComposerMessagesFinder
end end
def check_get_a_room(min_users_posted: 5) def check_get_a_room(min_users_posted: 5)
return unless @user.guardian.can_send_private_messages?
return unless educate_reply?(:notified_about_get_a_room) return unless educate_reply?(:notified_about_get_a_room)
return unless @details[:post_id].present? return unless @details[:post_id].present?
return if @topic.category&.read_restricted return if @topic.category&.read_restricted

View File

@ -441,6 +441,23 @@ RSpec.describe ComposerMessagesFinder do
SiteSetting.educate_until_posts = 10 SiteSetting.educate_until_posts = 10
user.stubs(:post_count).returns(11) user.stubs(:post_count).returns(11)
SiteSetting.get_a_room_threshold = 2 SiteSetting.get_a_room_threshold = 2
SiteSetting.personal_message_enabled_groups = Group::AUTO_GROUPS[:everyone]
end
context "when user can't send private messages" do
fab!(:group) { Fabricate(:group) }
before { SiteSetting.personal_message_enabled_groups = group.id }
it "does not show the message" do
expect(
ComposerMessagesFinder.new(
user,
composer_action: "reply",
topic_id: topic.id,
post_id: op.id,
).check_get_a_room(min_users_posted: 2),
).to be_blank
end
end end
it "does not show the message for new topics" do it "does not show the message for new topics" do