FIX: first post true if user creates topic first (#8139)

Reported here: https://meta.discourse.org/t/user-was-banned-for-posting-a-reply-within-3-seconds/128823/12
The problem here is the user could create a topic, then reply and get
silenced on the second time (though technically their first post) for being below the
min_first_post_typing_time threshold.
This commit is contained in:
Justin DiRose 2019-10-02 14:51:40 -05:00 committed by Robin Ward
parent dbb33f08a9
commit 63fabdb6f2
2 changed files with 19 additions and 1 deletions

View File

@ -40,7 +40,8 @@ class NewPostManager
!!(
args[:first_post_checks] &&
user.post_count == 0
user.post_count == 0 &&
user.topic_count == 0
)
end

View File

@ -859,6 +859,23 @@ describe PostsController do
expect(user).not_to be_silenced
end
it "doesn't enqueue posts when user first creates a topic" do
user.user_stat.update_column(:topic_count, 1)
post "/posts.json", params: {
raw: 'this is the test content',
title: 'this is the test title for the topic',
composer_open_duration_msecs: 204,
typing_duration_msecs: 100,
topic_id: topic.id
}
expect(response.status).to eq(200)
parsed = ::JSON.parse(response.body)
expect(parsed["action"]).not_to be_present
end
it "doesn't enqueue replies when the topic is closed" do
topic = Fabricate(:closed_topic)