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
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
3 changed files with 22 additions and 2 deletions

View file

@ -10,7 +10,7 @@ To match usernames to actors, Mobilizon uses [WebFinger](https://tools.ietf.org/
## Instance subscriptions ## Instance subscriptions
Instances subscribe to each other through an internal actor named `relay@instance.tld` that publishes (through `Announce`) every created content to it's followers. Each content creation share is saved so that updates and deletes are correctly sent to every Instances subscribe to each other through an internal actor named `relay@instance.tld` that publishes (through `Announce`) every created content to it's followers. Each content creation share is saved so that updates and deletes are correctly sent to every relay subscriber.
## Activities ## Activities
@ -46,6 +46,9 @@ See [the corresponding issue](https://framagit.org/framasoft/mobilizon/issues/32
Accepted values: `allow_all`, `closed`, `moderated` (not used at the moment) Accepted values: `allow_all`, `closed`, `moderated` (not used at the moment)
!!! info
We also support PeerTube's `commentEnabled` property as a fallback. It is set to `true` only when `repliesModeration` is equal to `allow_all`.
Example: Example:
```json ```json
{ {
@ -53,6 +56,7 @@ Example:
"...", "...",
{ {
"mz": "https://joinmobilizon.org/ns#", "mz": "https://joinmobilizon.org/ns#",
"pt": "https://joinpeertube.org/ns#",
"repliesModerationOption": { "repliesModerationOption": {
"@id": "mz:repliesModerationOption", "@id": "mz:repliesModerationOption",
"@type": "mz:repliesModerationOptionType" "@type": "mz:repliesModerationOptionType"
@ -60,11 +64,16 @@ Example:
"repliesModerationOptionType": { "repliesModerationOptionType": {
"@id": "mz:repliesModerationOptionType", "@id": "mz:repliesModerationOptionType",
"@type": "rdfs:Class" "@type": "rdfs:Class"
},
"commentsEnabled": {
"@id": "pt:commentsEnabled",
"@type": "sc:Boolean"
} }
} }
], ],
"...": "...", "...": "...",
"repliesModerationOption": "allow_all", "repliesModerationOption": "allow_all",
"commentsEnabled": true,
"type": "Event", "type": "Event",
"url": "http://mobilizon1.com/events/8cf76e9f-c426-4912-9cd6-c7030b969611" "url": "http://mobilizon1.com/events/8cf76e9f-c426-4912-9cd6-c7030b969611"
} }

View file

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

View file

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