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