posts: clean up delete! method.

* Remove unused `ban` and `without_mod_action` options.

* Don't try to set the `is_banned` flag during deletion.

* Don't create modactions for automatic "unapproved in 3 days"
  deletions, only to delete them after the fact.
This commit is contained in:
evazion
2020-08-03 20:00:47 -05:00
parent bca1f122d0
commit 157cb96551
4 changed files with 18 additions and 46 deletions

View File

@@ -2,36 +2,19 @@ class PostPruner
def prune!
prune_pending!
prune_flagged!
prune_mod_actions!
end
protected
def prune_pending!
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|
post.delete!("Unapproved in three days")
rescue PostFlag::Error
# swallow
end
Post.pending.expired.each do |post|
post.delete!("Unapproved in three days", user: User.system)
end
end
def prune_flagged!
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
post.delete!("Unapproved in three days after returning to moderation queue")
rescue PostFlag::Error
# swallow
end
end
Post.flagged.each do |post|
if post.flags.unresolved.old.any?
post.delete!("Unapproved in three days after returning to moderation queue", user: User.system)
end
end
end
def prune_mod_actions!
ModAction.where(["creator_id = ? and description like ?", User.system.id, "deleted post %"]).destroy_all
end
end