FIX: limit_topics_per_day should only apply to regular topics (#11127)

PMs were being evaluted by both the limit_topics_per_day and limit_private_messages_per_day rate limiters when it should only be the latter.
This commit is contained in:
tshenry
2020-11-04 16:23:49 -08:00
committed by GitHub
parent 1ec76ff8d4
commit d778d99b55
2 changed files with 24 additions and 0 deletions

View File

@ -2215,6 +2215,29 @@ describe Topic do
end
end
context "per day personal message limit" do
before do
SiteSetting.max_personal_messages_per_day = 1
SiteSetting.max_topics_per_day = 0
SiteSetting.max_topics_in_first_day = 0
RateLimiter.enable
end
after do
RateLimiter.clear_all!
RateLimiter.disable
end
it "limits according to max_personal_messages_per_day" do
user1 = Fabricate(:user)
user2 = Fabricate(:user)
create_post(user: user, archetype: 'private_message', target_usernames: [user1.username, user2.username])
expect {
create_post(user: user, archetype: 'private_message', target_usernames: [user1.username, user2.username])
}.to raise_error(RateLimiter::LimitExceeded)
end
end
describe ".count_exceeds_minimun?" do
before { SiteSetting.minimum_topics_similar = 20 }