FIX: Limit personal message participants when converting from topic (#9343)

Previously all topic posters would be added which could lead to major performance issues. Now if there are too many posters, only the acting user will be added as a participant.
This commit is contained in:
David Taylor
2020-04-03 16:42:01 +01:00
committed by GitHub
parent 91fff746a4
commit 3cfe086a94
3 changed files with 17 additions and 1 deletions

View File

@@ -152,6 +152,18 @@ describe TopicConverter do
expect(Notification.exists?(user_notification.id)).to eq(false)
expect(Notification.exists?(admin_notification.id)).to eq(true)
end
it "limits PM participants" do
SiteSetting.max_allowed_message_recipients = 2
Fabricate(:post, topic: topic)
Fabricate(:post, topic: topic)
private_message = topic.convert_to_private_message(post.user)
# Skips posters and just adds the acting user
expect(private_message.topic_allowed_users.count).to eq(1)
end
end
context 'topic has replies' do