feat(poc): Disable widget based on country (#6658)
This commit is contained in:
15
app/services/ip_lookup_service.rb
Normal file
15
app/services/ip_lookup_service.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class IpLookupService
|
||||
def perform(ip_address)
|
||||
return if ip_address.blank? || !ip_database_available?
|
||||
|
||||
Geocoder.search(ip_address).first
|
||||
rescue Errno::ETIMEDOUT => e
|
||||
Rails.logger.warn "Exception: IP resolution failed :#{e.message}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ip_database_available?
|
||||
File.exist?(GeocoderConfiguration::LOOK_UP_DB)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user