Support pt:CommentsEnabled in addition to mz:repliesModeration

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-12-16 11:46:19 +01:00
parent afa495c9c2
commit 14176ccc89
3 changed files with 22 additions and 2 deletions

View File

@@ -119,6 +119,7 @@ defmodule Mobilizon.Service.ActivityPub.Converter.Event do
"tag" => event.tags |> ConverterUtils.build_tags(),
"maximumAttendeeCapacity" => event.options.maximum_attendee_capacity,
"repliesModerationOption" => event.options.comment_moderation,
"commentsEnabled" => event.options.comment_moderation == :allow_all,
# "draft" => event.draft,
"ical:status" => event.status |> to_string |> String.upcase(),
"id" => event.url,
@@ -140,7 +141,12 @@ defmodule Mobilizon.Service.ActivityPub.Converter.Event do
defp get_options(object) do
%{
maximum_attendee_capacity: object["maximumAttendeeCapacity"],
comment_moderation: object["repliesModerationOption"]
comment_moderation:
Map.get(
object,
"repliesModerationOption",
if(Map.get(object, "commentsEnabled", true), do: :allow_all, else: :closed)
)
}
end

View File

@@ -32,6 +32,7 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
%{
"sc" => "http://schema.org#",
"ical" => "http://www.w3.org/2002/12/cal/ical#",
"pt" => "https://joinpeertube.org/ns#",
"Hashtag" => "as:Hashtag",
"category" => "sc:category",
"uuid" => "sc:identifier",
@@ -45,6 +46,10 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
"@id" => "mz:repliesModerationOption",
"@type" => "mz:repliesModerationOptionType"
},
"commentsEnabled" => %{
"@type" => "sc:Boolean",
"@id" => "pt:commentsEnabled"
},
"joinModeType" => %{
"@id" => "mz:joinModeType",
"@type" => "rdfs:Class"