Fixed error if no geo location backend is selected.
This commit is contained in:
parent
b0af4f85ee
commit
92c0cb9da8
6 changed files with 14 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue