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 e0547ff468
commit b5e872a670

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