Use enum-generated scope for `IpBlock` in CLI (#28144)

shrike
Matt Jankowski 2024-03-14 05:31:15 -04:00 committed by GitHub
parent 681a89f684
commit 19cbadfbd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View File

@ -23,7 +23,7 @@ class IpBlock < ApplicationRecord
sign_up_requires_approval: 5000,
sign_up_block: 5500,
no_access: 9999,
}
}, prefix: true
validates :ip, :severity, presence: true
validates :ip, uniqueness: true

View File

@ -446,7 +446,7 @@ class User < ApplicationRecord
end
def sign_up_from_ip_requires_approval?
sign_up_ip.present? && IpBlock.sign_up_requires_approval.exists?(['ip >>= ?', sign_up_ip.to_s])
sign_up_ip.present? && IpBlock.severity_sign_up_requires_approval.exists?(['ip >>= ?', sign_up_ip.to_s])
end
def sign_up_email_requires_approval?

View File

@ -105,7 +105,7 @@ module Mastodon::CLI
tools. Only blocks with no_access severity are returned.
LONG_DESC
def export
IpBlock.where(severity: :no_access).find_each do |ip_block|
IpBlock.severity_no_access.find_each do |ip_block|
case options[:format]
when 'nginx'
say "deny #{ip_block.ip}/#{ip_block.ip.prefix};"