2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-15 00:00:37 +08:00
|
|
|
# This job will automatically act on records that have gone unhandled on a
|
|
|
|
# queue for a long time.
|
|
|
|
module Jobs
|
2019-10-02 12:01:53 +08:00
|
|
|
class AutoQueueHandler < ::Jobs::Scheduled
|
2017-09-15 00:00:37 +08:00
|
|
|
|
|
|
|
every 1.day
|
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
return unless SiteSetting.auto_handle_queued_age.to_i > 0
|
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
Reviewable
|
|
|
|
.where(status: Reviewable.statuses[:pending])
|
2017-09-15 00:00:37 +08:00
|
|
|
.where('created_at < ?', SiteSetting.auto_handle_queued_age.to_i.days.ago)
|
2019-01-04 01:03:01 +08:00
|
|
|
.each do |reviewable|
|
2017-09-15 00:00:37 +08:00
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
if reviewable.is_a?(ReviewableFlaggedPost)
|
2019-05-28 05:22:39 +08:00
|
|
|
reviewable.perform(Discourse.system_user, :ignore, expired: true)
|
2019-04-17 23:26:43 +08:00
|
|
|
elsif reviewable.is_a?(ReviewableQueuedPost)
|
2019-04-24 00:18:39 +08:00
|
|
|
reviewable.perform(Discourse.system_user, :reject_post)
|
2019-04-17 23:26:43 +08:00
|
|
|
elsif reviewable.is_a?(ReviewableUser)
|
2021-06-15 23:35:45 +08:00
|
|
|
reviewable.perform(Discourse.system_user, :delete_user)
|
2019-01-04 01:03:01 +08:00
|
|
|
end
|
2017-09-15 00:00:37 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|