Merge pull request #3838 from evazion/fix-3837

Fix #3837: Remove expired bans.
This commit is contained in:
Albert Yi
2018-09-05 12:03:46 -07:00
committed by GitHub
3 changed files with 20 additions and 0 deletions

View File

@@ -18,5 +18,6 @@ class DailyMaintenance
TokenBucket.prune!
TagChangeRequestPruner.warn_all
TagChangeRequestPruner.reject_all
Ban.prune!
end
end

View File

@@ -59,6 +59,12 @@ class Ban < ApplicationRecord
q
end
def self.prune!
expired.includes(:user).find_each do |ban|
ban.user.unban! if ban.user.ban_expired?
end
end
def initialize_banner_id
self.banner_id = CurrentUser.id if self.banner_id.blank?
end