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
ec638c205f
commit
04615698ab
@ -22,7 +22,7 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
||||
# We assume for now performer == organizer
|
||||
"performer" => organizer,
|
||||
"organizer" => organizer,
|
||||
"location" => render_one(event.physical_address, ObjectView, "place.json", as: :address),
|
||||
"location" => render_location(event),
|
||||
"eventStatus" =>
|
||||
if(event.status == :cancelled,
|
||||
do: "https://schema.org/EventCancelled",
|
||||
@ -67,8 +67,6 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
||||
}
|
||||
end
|
||||
|
||||
def render("place.json", nil), do: %{}
|
||||
|
||||
def render("post.json", %{post: %Post{} = post}) do
|
||||
%{
|
||||
"@context" => "https://schema.org",
|
||||
@ -82,4 +80,16 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
|
||||
"dateModified" => post.updated_at
|
||||
}
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user