Remove mod-only user revert system (#4178).

The mass undo system from #4178 replaces this system.

Followup to f2dccf8cf.
This commit is contained in:
evazion
2019-09-27 21:48:49 -05:00
parent 3b75dbf64f
commit a39b67b901
9 changed files with 1 additions and 118 deletions

View File

@@ -1,32 +0,0 @@
# reverts all changes made by a user
class UserRevert
THRESHOLD = 1_000
class TooManyChangesError < RuntimeError ; end
attr_reader :user_id
def initialize(user_id)
@user_id = user_id
end
def process
validate!
revert_post_changes
end
def validate!
if PostArchive.where(updater_id: user_id).count > THRESHOLD
raise TooManyChangesError.new("This user has too many changes to be reverted")
end
end
def revert_post_changes
PostArchive.where(updater_id: user_id).find_each do |x|
x.undo!
end
end
def self.can_revert?(user)
user.post_update_count <= THRESHOLD
end
end