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
|
|
|
|
class AutoQueueHandler < Jobs::Scheduled
|
|
|
|
|
|
|
|
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
|
|
|
|
.where(status: Reviewable.statuses[: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)
|
|
|
|
reviewable.perform(Discourse.system_user, :ignore)
|
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)
|
|
|
|
reviewable.perform(Discourse.system_user, :reject_user_delete)
|
2019-01-03 12:03:01 -05:00
|
|
|
end
|
2017-09-14 12:00:37 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|