FIX: when adding an IP to the spammer list, check the broader ban list

first

FEATURE: allow admins to search users using IP ranges
This commit is contained in:
Régis Hanol
2014-11-21 18:16:06 +01:00
parent 0847cb5ea7
commit 0398ab7514
5 changed files with 32 additions and 18 deletions

View File

@@ -1,3 +1,5 @@
require_dependency 'ip_addr'
# Responsible for destroying a User record
class UserDestroyer
@@ -45,16 +47,21 @@ class UserDestroyer
user.destroy.tap do |u|
if u
if opts[:block_email]
b = ScreenedEmail.block(u.email, ip_address: u.ip_address)
b.record_match! if b
end
if opts[:block_ip] && u.ip_address
b.record_match! if b = ScreenedIpAddress.watch(u.ip_address)
b = ScreenedIpAddress.watch(u.ip_address)
b.record_match! if b
if u.registration_ip_address && u.ip_address != u.registration_ip_address
b.record_match! if b = ScreenedIpAddress.watch(u.registration_ip_address)
b = ScreenedIpAddress.watch(u.registration_ip_address)
b.record_match! if b
end
end
Post.with_deleted.where(user_id: user.id).update_all("user_id = NULL")
# If this user created categories, fix those up: