Skip to content

Commit

Permalink
FIX: do not show send pm prompt when user cant pm (discourse#25912)
Browse files Browse the repository at this point in the history
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?"
  • Loading branch information
jjaffeux authored Feb 27, 2024
1 parent 3736d66 commit 64e8ad1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/composer_messages_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def check_dominating_topic
end

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 @details[:post_id].present?
return if @topic.category&.read_restricted
Expand Down
17 changes: 17 additions & 0 deletions spec/lib/composer_messages_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,23 @@
SiteSetting.educate_until_posts = 10
user.stubs(:post_count).returns(11)
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

it "does not show the message for new topics" do
Expand Down

0 comments on commit 64e8ad1

Please sign in to comment.