FIX: Do not invite whisper or small action posters (#18123)

If a topic is converted to a private message, all posters were invited
to the new private message. This included users who only whispered or
posted small actions.
This commit is contained in:
Bianca Nenciu 2022-08-29 15:52:54 +03:00 committed by GitHub
parent f351200683
commit 446eb40bb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -63,7 +63,9 @@ class TopicConverter
private
def posters
@posters ||= @topic.posts.distinct.pluck(:user_id)
@posters ||= @topic.posts
.where.not(post_type: [Post.types[:small_action], Post.types[:whisper]])
.distinct.pluck(:user_id)
end
def increment_users_post_count

View File

@ -169,6 +169,17 @@ RSpec.describe TopicConverter do
expect(topic_user.reload.notification_level).to eq(TopicUser.notification_levels[:watching])
end
it "invites only users with regular posts" do
post2 = Fabricate(:post, topic: topic)
whipser_post = Fabricate(:post, topic: topic, post_type: Post.types[:whisper])
small_action_post = Fabricate(:post, topic: topic, post_type: Post.types[:small_action])
topic.convert_to_private_message(admin)
expect(topic.reload.topic_allowed_users.pluck(:user_id))
.to contain_exactly(admin.id, post.user_id, post2.user_id)
end
it "changes user_action type" do
Jobs.run_immediately!
UserActionManager.enable