diff --git a/README.md b/README.md index 4aaca44..4346985 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -This project is a *fork* of [the original BirdsiteLIVE from NicolasConstant](https://github.com/NicolasConstant/BirdsiteLive). Changes made in this fork include: +This project is a *fork* of [the original BirdsiteLIVE from NicolasConstant](https://github.com/NicolasConstant/BirdsiteLive). This fork runs in production on [a large BirdsiteLIVE instance](https://twtr.plus). Changes made in this fork include: * Rework About page entirely - also disclose unlisted accounts and federation restrictions * Cache Tweets so that, for example, Announces do not hit rate limits diff --git a/src/BirdsiteLive.ActivityPub/Models/Activity.cs b/src/BirdsiteLive.ActivityPub/Models/Activity.cs index 8c78091..9ae7d6c 100644 --- a/src/BirdsiteLive.ActivityPub/Models/Activity.cs +++ b/src/BirdsiteLive.ActivityPub/Models/Activity.cs @@ -1,12 +1,30 @@ -using System.Text.Json.Serialization; +using System.Collections.Generic; +using System.Text.Json.Serialization; using Newtonsoft.Json; namespace BirdsiteLive.ActivityPub { public class Activity { + [Newtonsoft.Json.JsonIgnore] + public static readonly object[] DefaultContext = new object[] { + "https://www.w3.org/ns/activitystreams", + "https://w3id.org/security/v1", + new Dictionary + { + { "Emoji", "toot:Emoji" }, + { "Hashtag", "as:Hashtag" }, + { "PropertyValue", "schema:PropertyValue" }, + { "value", "schema:value" }, + { "sensitive", "as:sensitive" }, + + { "schema", "http://schema.org#" }, + { "toot", "https://joinmastodon.org/ns#" } + } + }; + [JsonProperty("@context")] - public object context { get; set; } + public object context { get; set; } = DefaultContext; public string id { get; set; } public string type { get; set; } public string actor { get; set; } diff --git a/src/BirdsiteLive.ActivityPub/Models/Actor.cs b/src/BirdsiteLive.ActivityPub/Models/Actor.cs index 8e9b6cd..12905be 100644 --- a/src/BirdsiteLive.ActivityPub/Models/Actor.cs +++ b/src/BirdsiteLive.ActivityPub/Models/Actor.cs @@ -12,7 +12,7 @@ namespace BirdsiteLive.ActivityPub //[JsonPropertyName("@context")] [JsonProperty("@context")] [JsonConverter(typeof(ContextArrayConverter))] - public string[] context { get; set; } = new[] { "https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1" }; + public object[] context { get; set; } = Activity.DefaultContext; public string id { get; set; } public string type { get; set; } public string followers { get; set; } diff --git a/src/BirdsiteLive.ActivityPub/Models/Followers.cs b/src/BirdsiteLive.ActivityPub/Models/Followers.cs index 85c44d2..1a25ff6 100644 --- a/src/BirdsiteLive.ActivityPub/Models/Followers.cs +++ b/src/BirdsiteLive.ActivityPub/Models/Followers.cs @@ -7,7 +7,7 @@ namespace BirdsiteLive.ActivityPub.Models { [JsonProperty("@context")] [JsonConverter(typeof(ContextArrayConverter))] - public string context { get; set; } = "https://www.w3.org/ns/activitystreams"; + public object[] context { get; set; } = Activity.DefaultContext; public string id { get; set; } public string type { get; set; } = "OrderedCollection"; diff --git a/src/BirdsiteLive.ActivityPub/Models/Note.cs b/src/BirdsiteLive.ActivityPub/Models/Note.cs index fc6dc5b..2c19e9b 100644 --- a/src/BirdsiteLive.ActivityPub/Models/Note.cs +++ b/src/BirdsiteLive.ActivityPub/Models/Note.cs @@ -1,5 +1,6 @@ using BirdsiteLive.ActivityPub.Converters; using Newtonsoft.Json; +using System.Collections.Generic; namespace BirdsiteLive.ActivityPub.Models { @@ -7,7 +8,7 @@ namespace BirdsiteLive.ActivityPub.Models { [JsonProperty("@context")] [JsonConverter(typeof(ContextArrayConverter))] - public string[] context { get; set; } = new[] { "https://www.w3.org/ns/activitystreams" }; + public object[] context { get; set; } = Activity.DefaultContext; public string id { get; set; } public string type { get; } = "Note";