fix(activitypub): compact ical:status in activitystream data

Was kept for no other reason than disambiguation with https://schema.org/status, but no need if we
specify the correct alias in the context.

Keeps a fallback for older versions compatibility

Closes #1378

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-12-04 13:48:04 +01:00
parent 10ce812660
commit 5e8f9afb62
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
3 changed files with 17 additions and 1 deletions

View File

@ -165,6 +165,10 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
"todos" => %{ "todos" => %{
"@id" => "mz:todos", "@id" => "mz:todos",
"@type" => "@id" "@type" => "@id"
},
"status" => %{
"@id" => "ical:status",
"@type" => "ical:status"
} }
} }
] ]

View File

@ -81,7 +81,11 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Event do
external_participation_url: object["externalParticipationUrl"], external_participation_url: object["externalParticipationUrl"],
options: options, options: options,
metadata: metadata, metadata: metadata,
status: object |> Map.get("ical:status", "CONFIRMED") |> String.downcase(), # Remove fallback in MBZ 5.x
status:
object
|> Map.get("status", Map.get(object, "ical:status", "CONFIRMED"))
|> String.downcase(),
online_address: object |> Map.get("attachment", []) |> get_online_address(), online_address: object |> Map.get("attachment", []) |> get_online_address(),
phone_address: object["phoneAddress"], phone_address: object["phoneAddress"],
draft: object["draft"] == true, draft: object["draft"] == true,
@ -142,7 +146,9 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Event do
"anonymousParticipationEnabled" => event.options.anonymous_participation, "anonymousParticipationEnabled" => event.options.anonymous_participation,
"attachment" => Enum.map(event.metadata, &EventMetadataConverter.metadata_to_as/1), "attachment" => Enum.map(event.metadata, &EventMetadataConverter.metadata_to_as/1),
"draft" => event.draft, "draft" => event.draft,
# Remove me in MBZ 5.x
"ical:status" => event.status |> to_string |> String.upcase(), "ical:status" => event.status |> to_string |> String.upcase(),
"status" => event.status |> to_string |> String.upcase(),
"id" => event.url, "id" => event.url,
"url" => event.url, "url" => event.url,
"inLanguage" => event.language, "inLanguage" => event.language,

View File

@ -49,6 +49,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"name" => @event_title, "name" => @event_title,
"repliesModerationOption" => nil, "repliesModerationOption" => nil,
"startTime" => @event_begins_on, "startTime" => @event_begins_on,
"status" => "CONFIRMED",
"tag" => [], "tag" => [],
"to" => [@ap_public], "to" => [@ap_public],
"type" => "Event" "type" => "Event"
@ -96,6 +97,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"name" => @event_title, "name" => @event_title,
"repliesModerationOption" => nil, "repliesModerationOption" => nil,
"startTime" => @event_begins_on, "startTime" => @event_begins_on,
"status" => "CONFIRMED",
"tag" => [], "tag" => [],
"to" => [^followers_url], "to" => [^followers_url],
"type" => "Event" "type" => "Event"
@ -152,6 +154,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"name" => @event_title, "name" => @event_title,
"repliesModerationOption" => nil, "repliesModerationOption" => nil,
"startTime" => @event_begins_on, "startTime" => @event_begins_on,
"status" => "CONFIRMED",
"tag" => [], "tag" => [],
"to" => [@ap_public], "to" => [@ap_public],
"type" => "Event" "type" => "Event"
@ -200,6 +203,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"name" => @event_updated_title, "name" => @event_updated_title,
"repliesModerationOption" => nil, "repliesModerationOption" => nil,
"startTime" => @event_begins_on, "startTime" => @event_begins_on,
"status" => "CONFIRMED",
"tag" => [], "tag" => [],
"to" => [@ap_public], "to" => [@ap_public],
"type" => "Event" "type" => "Event"
@ -260,6 +264,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"name" => @event_updated_title, "name" => @event_updated_title,
"repliesModerationOption" => nil, "repliesModerationOption" => nil,
"startTime" => @event_begins_on, "startTime" => @event_begins_on,
"status" => "CONFIRMED",
"tag" => [], "tag" => [],
"to" => [@ap_public], "to" => [@ap_public],
"type" => "Event" "type" => "Event"
@ -320,6 +325,7 @@ defmodule Mobilizon.Federation.ActivityPub.Types.EventsTest do
"name" => @event_updated_title, "name" => @event_updated_title,
"repliesModerationOption" => nil, "repliesModerationOption" => nil,
"startTime" => @event_begins_on, "startTime" => @event_begins_on,
"status" => "CONFIRMED",
"tag" => [], "tag" => [],
"to" => [@ap_public], "to" => [@ap_public],
"type" => "Event" "type" => "Event"