diff --git a/app/models/user_device.rb b/app/models/user_device.rb index 094597c17..ce5976bd9 100644 --- a/app/models/user_device.rb +++ b/app/models/user_device.rb @@ -23,7 +23,10 @@ store device for user # get location info location_details = Service::GeoIp.location(ip) - location = location_details['country_name'] + location = 'unknown' + if location_details + location = location_details['country_name'] + end # find device by fingerprint if fingerprint diff --git a/lib/application_lib.rb b/lib/application_lib.rb index a5e94864f..8eb8f5fce 100644 --- a/lib/application_lib.rb +++ b/lib/application_lib.rb @@ -20,6 +20,7 @@ returns def load_adapter_by_setting(setting) adapter = Setting.get(setting) return if !adapter + return if adapter.empty? # load backend load_adapter(adapter) diff --git a/lib/service/geo_calendar.rb b/lib/service/geo_calendar.rb index 5fe8744f1..0cabe01c3 100644 --- a/lib/service/geo_calendar.rb +++ b/lib/service/geo_calendar.rb @@ -57,7 +57,7 @@ returns def self.location(address = nil) # load backend - backend = load_adapter_by_setting( 'geo_calendar_backend' ) + backend = load_adapter_by_setting('geo_calendar_backend') return if !backend # db lookup diff --git a/lib/service/geo_ip.rb b/lib/service/geo_ip.rb index a2a6291c4..34cc03521 100644 --- a/lib/service/geo_ip.rb +++ b/lib/service/geo_ip.rb @@ -8,7 +8,7 @@ module Service lookup location based on ip or hostname - result = Service::GeoIp.location( '172.0.0.1' ) + result = Service::GeoIp.location('172.0.0.1') returns @@ -31,7 +31,7 @@ returns def self.location(address) # load backend - backend = load_adapter_by_setting( 'geo_ip_backend' ) + backend = load_adapter_by_setting('geo_ip_backend') return if !backend # db lookup diff --git a/lib/service/geo_location.rb b/lib/service/geo_location.rb index 690e14830..853cc7703 100644 --- a/lib/service/geo_location.rb +++ b/lib/service/geo_location.rb @@ -19,7 +19,7 @@ returns def self.geocode(address) # load backend - backend = load_adapter_by_setting( 'geo_location_backend' ) + backend = load_adapter_by_setting('geo_location_backend') return if !backend # db lookup @@ -41,7 +41,7 @@ returns def self.reverse_geocode(lat, lng) # load backend - backend = load_adapter_by_setting( 'geo_location_backend' ) + backend = load_adapter_by_setting('geo_location_backend') return if !backend # db lookup diff --git a/lib/service/image.rb b/lib/service/image.rb index 4dd1fb78b..6936d41a9 100644 --- a/lib/service/image.rb +++ b/lib/service/image.rb @@ -8,7 +8,7 @@ module Service lookup user image based on email address - file = Service::Image.user( 'skywalker@zammad.org' ) + file = Service::Image.user('skywalker@zammad.org') returns @@ -22,7 +22,7 @@ returns def self.user(address) # load backend - backend = load_adapter_by_setting( 'image_backend' ) + backend = load_adapter_by_setting('image_backend') return if !backend backend.user(address) @@ -48,7 +48,7 @@ returns def self.organization(domain) # load backend - backend = load_adapter_by_setting( 'image_backend' ) + backend = load_adapter_by_setting('image_backend') return if !backend backend.organization(domain) @@ -69,7 +69,7 @@ returns def self.organization_suggest(domain) # load backend - backend = load_adapter_by_setting( 'image_backend' ) + backend = load_adapter_by_setting('image_backend') return if !backend result = backend.organization_suggest(domain)