eBooru/app/logical/post_pruner.rb

24 lines
481 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
class PostPruner
DELETION_WINDOW = 30
def prune!
2013-04-09 15:31:49 -04:00
Post.without_timeout do
prune_pending!
end
end
2013-03-19 08:10:10 -04:00
protected
def prune_pending!
CurrentUser.as_system do
2023-12-03 09:36:37 -05:00
Post.where("is_deleted = ? and is_pending = ? and created_at < ?", false, true, DELETION_WINDOW.days.ago).find_each do |post|
post.delete!("Unapproved in #{DELETION_WINDOW} days")
rescue PostFlag::Error
# swallow
end
end
end
end