From dc3353c60859e60dc56f884e289ad1f4bdcf38f7 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 18 Dec 2019 11:03:04 +0100 Subject: [PATCH] Move from Schema.org Place to AS Place with Schema.org properties See https://socialhub.activitypub.rocks/t/how-to-represent-places-in-an-event/413 Signed-off-by: Thomas Citharel --- lib/service/activity_pub/converter/address.ex | 12 +++++------- lib/service/activity_pub/utils.ex | 6 ------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/service/activity_pub/converter/address.ex b/lib/service/activity_pub/converter/address.ex index e5ff70302..413c23c30 100644 --- a/lib/service/activity_pub/converter/address.ex +++ b/lib/service/activity_pub/converter/address.ex @@ -35,11 +35,11 @@ defmodule Mobilizon.Service.ActivityPub.Converter.Address do }) end - if is_nil(object["geo"]) do + if is_nil(object["latitude"]) or is_nil(object["longitude"]) do res else geo = %Geo.Point{ - coordinates: {object["geo"]["latitude"], object["geo"]["longitude"]}, + coordinates: {object["latitude"], object["longitude"]}, srid: 4326 } @@ -70,11 +70,9 @@ defmodule Mobilizon.Service.ActivityPub.Converter.Address do if is_nil(address.geom) do res else - Map.put(res, "geo", %{ - "type" => "GeoCoordinates", - "latitude" => address.geom.coordinates |> elem(0), - "longitude" => address.geom.coordinates |> elem(1) - }) + res + |> Map.put("latitude", address.geom.coordinates |> elem(0)) + |> Map.put("longitude", address.geom.coordinates |> elem(1)) end end end diff --git a/lib/service/activity_pub/utils.ex b/lib/service/activity_pub/utils.ex index dc8e7eb95..586fb890a 100644 --- a/lib/service/activity_pub/utils.ex +++ b/lib/service/activity_pub/utils.ex @@ -41,17 +41,11 @@ defmodule Mobilizon.Service.ActivityPub.Utils do "@id" => "sc:location", "@type" => "sc:Place" }, - "Place" => "sc:Place", "PostalAddress" => "sc:PostalAddress", - "GeoCoordinates" => "sc:GeoCoordinates", "address" => %{ "@id" => "sc:address", "@type" => "sc:PostalAddress" }, - "geo" => %{ - "@id" => "sc:geo", - "@type" => "sc:GeoCoordinates" - }, "addressCountry" => "sc:addressCountry", "addressRegion" => "sc:addressRegion", "postalCode" => "sc:postalCode",