discourse/app/jobs/scheduled/auto_queue_handler.rb
Roman Rizzi 4dc8c3c409
FEATURE: Blocking is optional when deleting a user from the review queue. (#13375)
Subclasses must call #delete_user_actions inside build_actions to support user deletion. The method adds a delete user bundle, which has a delete and a delete + block option. Every subclass is responsible for implementing these actions.
2021-06-15 12:35:45 -03:00

29 lines
877 B
Ruby

# frozen_string_literal: true
# This job will automatically act on records that have gone unhandled on a
# queue for a long time.
module Jobs
class AutoQueueHandler < ::Jobs::Scheduled
every 1.day
def execute(args)
return unless SiteSetting.auto_handle_queued_age.to_i > 0
Reviewable
.where(status: Reviewable.statuses[:pending])
.where('created_at < ?', SiteSetting.auto_handle_queued_age.to_i.days.ago)
.each do |reviewable|
if reviewable.is_a?(ReviewableFlaggedPost)
reviewable.perform(Discourse.system_user, :ignore, expired: true)
elsif reviewable.is_a?(ReviewableQueuedPost)
reviewable.perform(Discourse.system_user, :reject_post)
elsif reviewable.is_a?(ReviewableUser)
reviewable.perform(Discourse.system_user, :delete_user)
end
end
end
end
end