switch approver and post pruners to use system user

This commit is contained in:
r888888888
2017-02-28 17:10:36 -08:00
parent 27f7f4f12e
commit e94edc9a75
3 changed files with 8 additions and 12 deletions

View File

@@ -7,10 +7,8 @@ class ApproverPruner
end
def prune!
admin = User.admins.first
inactive_approvers.each do |user|
CurrentUser.scoped(admin, "127.0.0.1") do
CurrentUser.scoped(User.system, "127.0.0.1") do
next if user.is_admin?
janitor_trial = JanitorTrial.where(user_id: user.id).first

View File

@@ -1,10 +1,4 @@
class PostPruner
attr_reader :admin
def initialize
@admin = User.where(:level => User::Levels::ADMIN).first
end
def prune!
Post.without_timeout do
prune_pending!
@@ -16,7 +10,7 @@ class PostPruner
protected
def prune_pending!
CurrentUser.scoped(admin, "127.0.0.1") do
CurrentUser.scoped(User.system, "127.0.0.1") do
Post.where("is_deleted = ? and is_pending = ? and created_at < ?", false, true, 3.days.ago).each do |post|
begin
post.flag!("Unapproved in three days")
@@ -29,7 +23,7 @@ protected
end
def prune_flagged!
CurrentUser.scoped(admin, "127.0.0.1") do
CurrentUser.scoped(User.system, "127.0.0.1") do
Post.where("is_deleted = ? and is_flagged = ?", false, true).each do |post|
if post.flags.unresolved.old.any?
begin
@@ -44,6 +38,6 @@ protected
end
def prune_mod_actions!
ModAction.destroy_all(["creator_id = ? and description like ?", admin.id, "deleted post %"])
ModAction.destroy_all(["creator_id = ? and description like ?", User.system.id, "deleted post %"])
end
end

View File

@@ -301,6 +301,10 @@ class User < ActiveRecord::Base
extend ActiveSupport::Concern
module ClassMethods
def system
Danbooru.config.system_user
end
def level_hash
return {
"Member" => Levels::MEMBER,