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

Compare commits

...

2 commits

Author SHA1 Message Date
Matt Jankowski
c47d141748
Merge f344c4d0ff into 549ab089ee 2024-07-31 11:08:53 +00:00
Matt Jankowski
f344c4d0ff Use enum-generated IpBlock.severity... scopes 2024-07-30 08:51:40 -04:00
2 changed files with 2 additions and 2 deletions

View file

@ -16,6 +16,6 @@ module RegistrationHelper
end end
def ip_blocked?(remote_ip) 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
end end

View file

@ -36,7 +36,7 @@ class IpBlock < ApplicationRecord
class << self class << self
def blocked?(remote_ip) 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) blocked_ips_map.include?(remote_ip)
end end
end end