[ModActions] Display ip ban subnet and reason

This commit is contained in:
Earlopain 2023-04-06 15:49:46 +02:00
parent 63db033dc2
commit 7c0fec2be9
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
2 changed files with 13 additions and 4 deletions

View File

@ -28,9 +28,18 @@ class ModActionDecorator < ApplicationDecorator
### IP Ban ###
when "ip_ban_create"
"Created ip ban"
msg = "Created ip ban"
if CurrentUser.is_admin?
msg += " #{vals['ip_addr']}\nBan reason: #{vals['reason']}"
end
msg
when "ip_ban_delete"
"Removed ip ban"
msg = "Removed ip ban"
if CurrentUser.is_admin?
msg += " #{vals['ip_addr']}\nBan reason: #{vals['reason']}"
end
msg
### Ticket ###
when "ticket_update"

View File

@ -4,10 +4,10 @@ class IpBan < ApplicationRecord
validates :ip_addr, uniqueness: true
validate :validate_ip_addr
after_create do |rec|
ModAction.log(:ip_ban_create, { ip_addr: rec.ip_addr })
ModAction.log(:ip_ban_create, { ip_addr: rec.subnetted_ip, reason: rec.reason })
end
after_destroy do |rec|
ModAction.log(:ip_ban_delete, { ip_addr: rec.ip_addr })
ModAction.log(:ip_ban_delete, { ip_addr: rec.subnetted_ip, reason: rec.reason })
end
def self.is_banned?(ip_addr)