mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
16 lines
355 B
Ruby
16 lines
355 B
Ruby
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
|