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)
|
2023-02-16 04:40:11 -05:00
|
|
|
return if SiteSetting.auto_handle_queued_age.to_i.zero?
|
2017-09-14 12:00:37 -04:00
|
|
|
|
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|
|
|
|
|
if reviewable.is_a?(ReviewableFlaggedPost)
|
2023-03-02 10:40:53 -05:00
|
|
|
reviewable.perform(Discourse.system_user, :ignore_and_do_nothing, 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)
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2019-01-03 12:03:01 -05:00
|
|
|
end
|
2017-09-14 12:00:37 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|