1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Use enum-generated IpBlock.severity... scopes

This commit is contained in:
Matt Jankowski 2024-07-30 08:51:40 -04:00
parent 598ae4f2da
commit f344c4d0ff
2 changed files with 2 additions and 2 deletions

View file

@ -16,6 +16,6 @@ module RegistrationHelper
end
def ip_blocked?(remote_ip)
IpBlock.where(severity: :sign_up_block).exists?(['ip >>= ?', remote_ip.to_s])
IpBlock.severity_sign_up_block.exists?(['ip >>= ?', remote_ip.to_s])
end
end

View file

@ -36,7 +36,7 @@ class IpBlock < ApplicationRecord
class << self
def blocked?(remote_ip)
blocked_ips_map = Rails.cache.fetch(CACHE_KEY) { FastIpMap.new(IpBlock.where(severity: :no_access).pluck(:ip)) }
blocked_ips_map = Rails.cache.fetch(CACHE_KEY) { FastIpMap.new(severity_no_access.pluck(:ip)) }
blocked_ips_map.include?(remote_ip)
end
end