mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 04:43:43 +08:00
b58867b6e9
Includes support for flags, reviewable users and queued posts, with REST API backwards compatibility. Co-Authored-By: romanrizzi <romanalejandro@gmail.com> Co-Authored-By: jjaffeux <j.jaffeux@gmail.com>
25 lines
671 B
Ruby
25 lines
671 B
Ruby
# 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
|
|
|
|
Reviewable
|
|
.where(status: Reviewable.statuses[:pending])
|
|
.where('created_at < ?', SiteSetting.auto_handle_queued_age.to_i.days.ago)
|
|
.each do |reviewable|
|
|
|
|
if reviewable.is_a?(ReviewableFlaggedPost)
|
|
reviewable.perform(Discourse.system_user, :ignore)
|
|
else
|
|
reviewable.perform(Discourse.system_user, :reject)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|