Fix federating geo coordinates

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-09-06 12:46:29 +02:00
parent 7c71e9e04f
commit cc197d7638
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -36,15 +36,16 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Address do
})
end
if is_nil(object["latitude"]) or is_nil(object["longitude"]) do
res
else
geo = %Geo.Point{
coordinates: {object["longitude"], object["latitude"]},
srid: 4326
}
latitude = Map.get(object, "latitude")
longitude = Map.get(object, "longitude")
Map.put(res, "geom", geo)
if is_float(latitude) and is_float(longitude) do
Map.put(res, "geom", %Geo.Point{
coordinates: {longitude, latitude},
srid: 4326
})
else
res
end
end
@ -72,8 +73,8 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Address do
res
else
res
|> Map.put("longitude", address.geom.coordinates |> elem(1))
|> Map.put("latitude", address.geom.coordinates |> elem(0))
|> Map.put("longitude", address.geom.coordinates |> elem(0))
|> Map.put("latitude", address.geom.coordinates |> elem(1))
end
end
end