diff --git a/lib/graphql/resolvers/event.ex b/lib/graphql/resolvers/event.ex index 86f56b564..1138b0bd8 100644 --- a/lib/graphql/resolvers/event.ex +++ b/lib/graphql/resolvers/event.ex @@ -496,7 +496,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do physical_address when is_map(physical_address) -> TimezoneDetector.detect( timezone, - physical_address.geom, + Map.get(physical_address, :geom), fallback_tz ) diff --git a/lib/service/timezone_detector.ex b/lib/service/timezone_detector.ex index fe0ad35e4..91d002b9f 100644 --- a/lib/service/timezone_detector.ex +++ b/lib/service/timezone_detector.ex @@ -8,7 +8,9 @@ defmodule Mobilizon.Service.TimezoneDetector do @doc """ Detect the most appropriate timezone from a value, a geographic set of coordinates and a fallback """ - @spec detect(String.t() | nil, detectable(), String.t()) :: String.t() + @spec detect(String.t() | nil, detectable() | nil, String.t()) :: String.t() + def detect(tz, nil, fallback), do: detect(tz, fallback) + def detect(nil, geo, fallback) do case TzWorld.timezone_at(geo) do {:ok, timezone} -> diff --git a/test/service/geospatial/addok_test.exs b/test/service/geospatial/addok_test.exs index bf698c9d8..d9f0778bd 100644 --- a/test/service/geospatial/addok_test.exs +++ b/test/service/geospatial/addok_test.exs @@ -28,6 +28,7 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do region: "69, Rhône, Auvergne-Rhône-Alpes", locality: "Lyon", description: "10 Rue Jangot", + timezone: "Europe/Paris", postal_code: "69007", street: "10 Rue Jangot", geom: %Geo.Point{coordinates: {4.842569, 45.751718}, properties: %{}, srid: 4326} @@ -54,6 +55,7 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do region: "69, Rhône, Auvergne-Rhône-Alpes", locality: "Lyon", description: "10 Rue Jangot", + timezone: "Europe/Paris", postal_code: "69007", street: "10 Rue Jangot", geom: %Geo.Point{coordinates: {4.842569, 45.751718}, properties: %{}, srid: 4326} diff --git a/test/service/geospatial/google_maps_test.exs b/test/service/geospatial/google_maps_test.exs index ab8833c6e..7f268c72c 100644 --- a/test/service/geospatial/google_maps_test.exs +++ b/test/service/geospatial/google_maps_test.exs @@ -69,6 +69,7 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do country: "France", postal_code: "69007", street: "10 Rue Jangot", + timezone: "Europe/Paris", geom: %Geo.Point{ coordinates: {4.8424032, 45.75164940000001}, properties: %{}, @@ -116,6 +117,7 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do country: "France", postal_code: "69007", street: "10bis Rue Jangot", + timezone: "Europe/Paris", geom: %Geo.Point{ coordinates: {4.8424966, 45.751725}, properties: %{}, diff --git a/test/service/geospatial/map_quest_test.exs b/test/service/geospatial/map_quest_test.exs index 4a1edf224..21464c494 100644 --- a/test/service/geospatial/map_quest_test.exs +++ b/test/service/geospatial/map_quest_test.exs @@ -55,6 +55,7 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do country: "FR", postal_code: "69007", street: "10 Rue Jangot", + timezone: "Europe/Paris", geom: %Geo.Point{ coordinates: {4.842566, 45.751714}, properties: %{}, @@ -88,6 +89,7 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do country: "FR", postal_code: "69007", street: "10 Rue Jangot", + timezone: "Europe/Paris", geom: %Geo.Point{ coordinates: {4.842569, 45.751718}, properties: %{}, diff --git a/test/service/geospatial/nominatim_test.exs b/test/service/geospatial/nominatim_test.exs index 40d2bd959..4177c0fee 100644 --- a/test/service/geospatial/nominatim_test.exs +++ b/test/service/geospatial/nominatim_test.exs @@ -31,6 +31,7 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do country: "France", postal_code: "69007", street: "10 Rue Jangot", + timezone: "Europe/Paris", geom: %Geo.Point{ coordinates: {4.8425657, 45.7517141}, properties: %{}, @@ -66,6 +67,7 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do country: "France", postal_code: "69007", street: "10 Rue Jangot", + timezone: "Europe/Paris", geom: %Geo.Point{ coordinates: {4.8425657, 45.7517141}, properties: %{}, diff --git a/test/service/geospatial/photon_test.exs b/test/service/geospatial/photon_test.exs index 7d3ba8221..48cfebc4c 100644 --- a/test/service/geospatial/photon_test.exs +++ b/test/service/geospatial/photon_test.exs @@ -30,6 +30,7 @@ defmodule Mobilizon.Service.Geospatial.PhotonTest do country: "France", postal_code: "69007", street: "10 Rue Jangot", + timezone: "Europe/Paris", geom: %Geo.Point{ coordinates: {4.8425657, 45.7517141}, properties: %{},