Add a VirtualLocation field to the event URL itself when location is not
defined Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
040aa56763
commit
992e3af237
@ -22,7 +22,7 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
|||||||
# We assume for now performer == organizer
|
# We assume for now performer == organizer
|
||||||
"performer" => organizer,
|
"performer" => organizer,
|
||||||
"organizer" => organizer,
|
"organizer" => organizer,
|
||||||
"location" => render_one(event.physical_address, ObjectView, "place.json", as: :address),
|
"location" => render_location(event),
|
||||||
"eventStatus" =>
|
"eventStatus" =>
|
||||||
if(event.status == :cancelled,
|
if(event.status == :cancelled,
|
||||||
do: "https://schema.org/EventCancelled",
|
do: "https://schema.org/EventCancelled",
|
||||||
@ -67,8 +67,6 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("place.json", nil), do: %{}
|
|
||||||
|
|
||||||
def render("post.json", %{post: %Post{} = post}) do
|
def render("post.json", %{post: %Post{} = post}) do
|
||||||
%{
|
%{
|
||||||
"@context" => "https://schema.org",
|
"@context" => "https://schema.org",
|
||||||
@ -82,4 +80,16 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
|||||||
"dateModified" => post.updated_at
|
"dateModified" => post.updated_at
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp render_location(%Event{physical_address: %Address{} = address}),
|
||||||
|
do: render_one(address, ObjectView, "place.json", as: :address)
|
||||||
|
|
||||||
|
# For now the Virtual Location of an event is it's own URL,
|
||||||
|
# but in the future it will be a special field
|
||||||
|
defp render_location(%Event{url: event_url}) do
|
||||||
|
%{
|
||||||
|
"@type" => "VirtualLocation",
|
||||||
|
"url" => event_url
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user