FEATURE: auto block fast typers
if tl0 enter text too fast they get automatically blocked, configurable
This commit is contained in:
parent
61536c911b
commit
6fdd53e3d6
|
@ -1078,6 +1078,8 @@ en:
|
|||
|
||||
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)"
|
||||
auto_block_fast_typers_on_first_post: "Automatically block users that do not meet min_first_post_typing_time"
|
||||
auto_block_fast_typers_max_trust_level: "Maximum trust level to auto block fast typers"
|
||||
|
||||
reply_by_email_enabled: "Enable replying to topics via email."
|
||||
reply_by_email_address: "Template for reply by email incoming email address, for example: %{reply_key}@reply.example.com or replies+%{reply_key}@example.com"
|
||||
|
|
|
@ -681,6 +681,8 @@ spam:
|
|||
num_flags_to_close_topic: 12
|
||||
auto_respond_to_flag_actions: true
|
||||
min_first_post_typing_time: 3000
|
||||
auto_block_fast_typers_on_first_post: true
|
||||
auto_block_fast_typers_max_trust_level: 0
|
||||
|
||||
rate_limits:
|
||||
unique_posts_mins:
|
||||
|
|
|
@ -28,23 +28,41 @@ class NewPostManager
|
|||
@sorted_handlers.sort_by! {|h| -h[:priority]}
|
||||
end
|
||||
|
||||
def self.user_needs_approval?(manager)
|
||||
def self.is_fast_typer?(manager)
|
||||
user = manager.user
|
||||
args = manager.args
|
||||
|
||||
args[:first_post_checks] &&
|
||||
user.post_count == 0 &&
|
||||
args[:typing_duration_msecs].to_i < SiteSetting.min_first_post_typing_time
|
||||
end
|
||||
|
||||
def self.user_needs_approval?(manager)
|
||||
user = manager.user
|
||||
|
||||
return false if user.staff?
|
||||
|
||||
(user.post_count < SiteSetting.approve_post_count) ||
|
||||
(user.trust_level < SiteSetting.approve_unless_trust_level.to_i) ||
|
||||
(
|
||||
args[:first_post_checks] &&
|
||||
user.post_count == 0 &&
|
||||
args[:typing_duration_msecs].to_i < SiteSetting.min_first_post_typing_time
|
||||
)
|
||||
is_fast_typer?(manager)
|
||||
end
|
||||
|
||||
def self.default_handler(manager)
|
||||
manager.enqueue('default') if user_needs_approval?(manager)
|
||||
if user_needs_approval?(manager)
|
||||
|
||||
result = manager.enqueue('default')
|
||||
|
||||
if is_fast_typer?(manager) &&
|
||||
SiteSetting.auto_block_fast_typers_on_first_post &&
|
||||
SiteSetting.auto_block_fast_typers_max_trust_level <= manager.user.trust_level
|
||||
|
||||
manager.user.update_columns(blocked: true)
|
||||
|
||||
end
|
||||
|
||||
result
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def self.queue_enabled?
|
||||
|
|
|
@ -492,6 +492,8 @@ describe PostsController do
|
|||
|
||||
expect(parsed["action"]).to eq("enqueued")
|
||||
|
||||
expect(user.blocked).to eq(true)
|
||||
|
||||
end
|
||||
|
||||
it 'creates the post' do
|
||||
|
|
Loading…
Reference in New Issue