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
|
# get location info
|
||||||
location_details = Service::GeoIp.location(ip)
|
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
|
# find device by fingerprint
|
||||||
if fingerprint
|
if fingerprint
|
||||||
|
|
|
@ -20,6 +20,7 @@ returns
|
||||||
def load_adapter_by_setting(setting)
|
def load_adapter_by_setting(setting)
|
||||||
adapter = Setting.get(setting)
|
adapter = Setting.get(setting)
|
||||||
return if !adapter
|
return if !adapter
|
||||||
|
return if adapter.empty?
|
||||||
|
|
||||||
# load backend
|
# load backend
|
||||||
load_adapter(adapter)
|
load_adapter(adapter)
|
||||||
|
|
|
@ -57,7 +57,7 @@ returns
|
||||||
def self.location(address = nil)
|
def self.location(address = nil)
|
||||||
|
|
||||||
# load backend
|
# load backend
|
||||||
backend = load_adapter_by_setting( 'geo_calendar_backend' )
|
backend = load_adapter_by_setting('geo_calendar_backend')
|
||||||
return if !backend
|
return if !backend
|
||||||
|
|
||||||
# db lookup
|
# db lookup
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Service
|
||||||
|
|
||||||
lookup location based on ip or hostname
|
lookup location based on ip or hostname
|
||||||
|
|
||||||
result = Service::GeoIp.location( '172.0.0.1' )
|
result = Service::GeoIp.location('172.0.0.1')
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ returns
|
||||||
def self.location(address)
|
def self.location(address)
|
||||||
|
|
||||||
# load backend
|
# load backend
|
||||||
backend = load_adapter_by_setting( 'geo_ip_backend' )
|
backend = load_adapter_by_setting('geo_ip_backend')
|
||||||
return if !backend
|
return if !backend
|
||||||
|
|
||||||
# db lookup
|
# db lookup
|
||||||
|
|
|
@ -19,7 +19,7 @@ returns
|
||||||
def self.geocode(address)
|
def self.geocode(address)
|
||||||
|
|
||||||
# load backend
|
# load backend
|
||||||
backend = load_adapter_by_setting( 'geo_location_backend' )
|
backend = load_adapter_by_setting('geo_location_backend')
|
||||||
return if !backend
|
return if !backend
|
||||||
|
|
||||||
# db lookup
|
# db lookup
|
||||||
|
@ -41,7 +41,7 @@ returns
|
||||||
def self.reverse_geocode(lat, lng)
|
def self.reverse_geocode(lat, lng)
|
||||||
|
|
||||||
# load backend
|
# load backend
|
||||||
backend = load_adapter_by_setting( 'geo_location_backend' )
|
backend = load_adapter_by_setting('geo_location_backend')
|
||||||
return if !backend
|
return if !backend
|
||||||
|
|
||||||
# db lookup
|
# db lookup
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Service
|
||||||
|
|
||||||
lookup user image based on email address
|
lookup user image based on email address
|
||||||
|
|
||||||
file = Service::Image.user( 'skywalker@zammad.org' )
|
file = Service::Image.user('skywalker@zammad.org')
|
||||||
|
|
||||||
returns
|
returns
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ returns
|
||||||
def self.user(address)
|
def self.user(address)
|
||||||
|
|
||||||
# load backend
|
# load backend
|
||||||
backend = load_adapter_by_setting( 'image_backend' )
|
backend = load_adapter_by_setting('image_backend')
|
||||||
return if !backend
|
return if !backend
|
||||||
|
|
||||||
backend.user(address)
|
backend.user(address)
|
||||||
|
@ -48,7 +48,7 @@ returns
|
||||||
def self.organization(domain)
|
def self.organization(domain)
|
||||||
|
|
||||||
# load backend
|
# load backend
|
||||||
backend = load_adapter_by_setting( 'image_backend' )
|
backend = load_adapter_by_setting('image_backend')
|
||||||
return if !backend
|
return if !backend
|
||||||
|
|
||||||
backend.organization(domain)
|
backend.organization(domain)
|
||||||
|
@ -69,7 +69,7 @@ returns
|
||||||
def self.organization_suggest(domain)
|
def self.organization_suggest(domain)
|
||||||
|
|
||||||
# load backend
|
# load backend
|
||||||
backend = load_adapter_by_setting( 'image_backend' )
|
backend = load_adapter_by_setting('image_backend')
|
||||||
return if !backend
|
return if !backend
|
||||||
|
|
||||||
result = backend.organization_suggest(domain)
|
result = backend.organization_suggest(domain)
|
||||||
|
|
Loading…
Reference in a new issue