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)
|
2023-02-16 17:40:11 +08:00
|
|
|
return if SiteSetting.auto_handle_queued_age.to_i.zero?
|
2017-09-15 00:00:37 +08:00
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
Reviewable
|
2021-12-09 01:12:24 +08:00
|
|
|
.pending
|
2017-09-15 00:00:37 +08:00
|
|
|
.where("created_at < ?", SiteSetting.auto_handle_queued_age.to_i.days.ago)
|
2024-05-24 06:42:21 +08:00
|
|
|
.find_each do |reviewable|
|
2019-01-04 01:03:01 +08:00
|
|
|
if reviewable.is_a?(ReviewableFlaggedPost)
|
2023-03-02 23:40:53 +08:00
|
|
|
reviewable.perform(Discourse.system_user, :ignore_and_do_nothing, 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)
|
2023-01-09 20:20:10 +08:00
|
|
|
end
|
2019-01-04 01:03:01 +08:00
|
|
|
end
|
2017-09-15 00:00:37 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|