feat(poc): Disable widget based on country (#6658)

This commit is contained in:
Pranav Raj S
2023-03-14 09:09:57 -07:00
committed by GitHub
parent e8a174f689
commit eb7070d946
8 changed files with 72 additions and 53 deletions

View 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