diff --git a/lib/composer_messages_finder.rb b/lib/composer_messages_finder.rb index d805e9847a9..efc230108fe 100644 --- a/lib/composer_messages_finder.rb +++ b/lib/composer_messages_finder.rb @@ -181,6 +181,7 @@ class ComposerMessagesFinder 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 diff --git a/spec/lib/composer_messages_finder_spec.rb b/spec/lib/composer_messages_finder_spec.rb index fcfca56de35..b76354754b4 100644 --- a/spec/lib/composer_messages_finder_spec.rb +++ b/spec/lib/composer_messages_finder_spec.rb @@ -441,6 +441,23 @@ RSpec.describe ComposerMessagesFinder do 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