FEATURE: Pause a topic instead of permanently closing when flag threshold is reached.
This commit is contained in:
parent
2fa82ba4ff
commit
ed577fbff8
|
@ -497,8 +497,18 @@ SQL
|
||||||
return if flags.sum { |f| f[1] } < SiteSetting.num_flags_to_close_topic
|
return if flags.sum { |f| f[1] } < SiteSetting.num_flags_to_close_topic
|
||||||
|
|
||||||
# the threshold has been reached, we will close the topic waiting for intervention
|
# the threshold has been reached, we will close the topic waiting for intervention
|
||||||
message = I18n.t("temporarily_closed_due_to_flags")
|
topic.update_status("closed", true, Discourse.system_user,
|
||||||
topic.update_status("closed", true, Discourse.system_user, message: message)
|
message: I18n.t(
|
||||||
|
"temporarily_closed_due_to_flags",
|
||||||
|
count: SiteSetting.num_hours_to_close_topic
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
topic.set_or_create_status_update(
|
||||||
|
TopicStatusUpdate.types[:open],
|
||||||
|
SiteSetting.num_hours_to_close_topic,
|
||||||
|
by_user: Discourse.system_user
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.auto_hide_if_needed(acting_user, post, post_action_type)
|
def self.auto_hide_if_needed(acting_user, post, post_action_type)
|
||||||
|
|
|
@ -1286,6 +1286,7 @@ en:
|
||||||
|
|
||||||
num_flaggers_to_close_topic: "Minimum number of unique flaggers that is required to automatically pause a topic for intervention"
|
num_flaggers_to_close_topic: "Minimum number of unique flaggers that is required to automatically pause a topic for intervention"
|
||||||
num_flags_to_close_topic: "Minimum number of active flags that is required to automatically pause a topic for intervention"
|
num_flags_to_close_topic: "Minimum number of active flags that is required to automatically pause a topic for intervention"
|
||||||
|
num_hours_to_close_topic: "Number of hours to pause a topic for intervention."
|
||||||
|
|
||||||
auto_respond_to_flag_actions: "Enable automatic reply when disposing a flag."
|
auto_respond_to_flag_actions: "Enable automatic reply when disposing a flag."
|
||||||
min_first_post_typing_time: "Minimum amount of time in milliseconds a user must type during first post, if threshold is not met post will automatically enter the needs approval queue. Set to 0 to disable (not recommended)"
|
min_first_post_typing_time: "Minimum amount of time in milliseconds a user must type during first post, if threshold is not met post will automatically enter the needs approval queue. Set to 0 to disable (not recommended)"
|
||||||
|
@ -1912,7 +1913,9 @@ en:
|
||||||
deferred: "Thanks for letting us know. We're looking into it."
|
deferred: "Thanks for letting us know. We're looking into it."
|
||||||
deferred_and_deleted: "Thanks for letting us know. We've removed the post."
|
deferred_and_deleted: "Thanks for letting us know. We've removed the post."
|
||||||
|
|
||||||
temporarily_closed_due_to_flags: "This topic is temporarily closed due to a large number of community flags."
|
temporarily_closed_due_to_flags:
|
||||||
|
one: "This topic is temporarily closed for 1 hour due to a large number of community flags."
|
||||||
|
other: "This topic is temporarily closed for %{count} hours due to a large number of community flags."
|
||||||
|
|
||||||
system_messages:
|
system_messages:
|
||||||
post_hidden:
|
post_hidden:
|
||||||
|
|
|
@ -944,6 +944,9 @@ spam:
|
||||||
max_age_unmatched_ips: 365
|
max_age_unmatched_ips: 365
|
||||||
num_flaggers_to_close_topic: 5
|
num_flaggers_to_close_topic: 5
|
||||||
num_flags_to_close_topic: 12
|
num_flags_to_close_topic: 12
|
||||||
|
num_hours_to_close_topic:
|
||||||
|
default: 4
|
||||||
|
min: 1
|
||||||
auto_respond_to_flag_actions: true
|
auto_respond_to_flag_actions: true
|
||||||
min_first_post_typing_time: 3000
|
min_first_post_typing_time: 3000
|
||||||
auto_block_fast_typers_on_first_post: true
|
auto_block_fast_typers_on_first_post: true
|
||||||
|
|
|
@ -447,11 +447,11 @@ describe PostAction do
|
||||||
expect(post.hidden).to eq(false)
|
expect(post.hidden).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "will automatically close a topic due to large community flagging" do
|
it "will automatically pause a topic due to large community flagging" do
|
||||||
SiteSetting.stubs(:flags_required_to_hide_post).returns(0)
|
SiteSetting.flags_required_to_hide_post = 0
|
||||||
|
SiteSetting.num_flags_to_close_topic = 3
|
||||||
SiteSetting.stubs(:num_flags_to_close_topic).returns(3)
|
SiteSetting.num_flaggers_to_close_topic = 2
|
||||||
SiteSetting.stubs(:num_flaggers_to_close_topic).returns(2)
|
SiteSetting.num_hours_to_close_topic = 1
|
||||||
|
|
||||||
topic = Fabricate(:topic)
|
topic = Fabricate(:topic)
|
||||||
post1 = create_post(topic: topic)
|
post1 = create_post(topic: topic)
|
||||||
|
@ -490,6 +490,11 @@ describe PostAction do
|
||||||
|
|
||||||
expect(topic.reload.closed).to eq(true)
|
expect(topic.reload.closed).to eq(true)
|
||||||
|
|
||||||
|
topic_status_update = TopicStatusUpdate.last
|
||||||
|
|
||||||
|
expect(topic_status_update.topic).to eq(topic)
|
||||||
|
expect(topic_status_update.execute_at).to be_within(1.second).of(1.hour.from_now)
|
||||||
|
expect(topic_status_update.status_type).to eq(TopicStatusUpdate.types[:open])
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue