Handle missing geolix database

Close #313

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-11-19 10:46:54 +01:00
parent 792a2deddb
commit 258550ec94
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -15,13 +15,13 @@ defmodule MobilizonWeb.Resolvers.Config do
geolix = Geolix.lookup(ip)
country_code =
case geolix.city do
case Map.get(geolix, :city) do
%{country: %Country{iso_code: country_code}} -> String.downcase(country_code)
_ -> nil
end
location =
case geolix.city do
case Map.get(geolix, :city) do
%{location: %Location{} = location} -> Map.from_struct(location)
_ -> nil
end