From bb6ec1bf1349f5342bdcfe12bfab9f82296fb432 Mon Sep 17 00:00:00 2001 From: Jenniferplusplus Date: Tue, 15 Oct 2024 22:39:57 -0500 Subject: [PATCH 1/2] Add sharedInbox to Actor And make OrderedCollection inherit from Collection --- Source/ActivityPub.Types/AS/APActor.cs | 13 +++++++++++++ .../AS/Collection/ASOrderedCollection.cs | 2 +- .../SimpleObjectDeserializationTests.cs | 2 ++ .../Serialization/SimpleObjectSerializationTests.cs | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Source/ActivityPub.Types/AS/APActor.cs b/Source/ActivityPub.Types/AS/APActor.cs index f6aaab1..00f0487 100644 --- a/Source/ActivityPub.Types/AS/APActor.cs +++ b/Source/ActivityPub.Types/AS/APActor.cs @@ -65,6 +65,15 @@ public required ASLink Outbox set => Entity.Outbox = value; } + /// + /// An optional endpoint used for wide delivery of activities addressed to public or other collections + /// + public ASLink? SharedInbox + { + get => Entity.SharedInbox; + set => Entity.SharedInbox = value; + } + /// /// A reference to an ActivityStreams collection of the actors that this actor is following. /// This is a list of everybody that the actor has followed, added as a side effect. @@ -155,6 +164,10 @@ public sealed class APActorEntity : ASEntity /// [JsonPropertyName("outbox")] public ASLink? Outbox { get; set; } + + /// + [JsonPropertyName("sharedInbox")] + public ASLink? SharedInbox { get; set; } /// [JsonPropertyName("following")] diff --git a/Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs b/Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs index d07f322..9b4c8d7 100644 --- a/Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs +++ b/Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs @@ -19,7 +19,7 @@ namespace ActivityPub.Types.AS.Collection; /// /// /// -public class ASOrderedCollection : ASObject, IASModel, IEnumerable> +public class ASOrderedCollection : ASCollection, IASModel, IEnumerable> { /// /// ActivityStreams type name for "OrderedCollection" types. diff --git a/Test/ActivityPub.Types.Tests/Integration/Deserialization/SimpleObjectDeserializationTests.cs b/Test/ActivityPub.Types.Tests/Integration/Deserialization/SimpleObjectDeserializationTests.cs index f926141..c77d833 100644 --- a/Test/ActivityPub.Types.Tests/Integration/Deserialization/SimpleObjectDeserializationTests.cs +++ b/Test/ActivityPub.Types.Tests/Integration/Deserialization/SimpleObjectDeserializationTests.cs @@ -49,6 +49,7 @@ public void ShouldIncludePropertiesFromBaseTypes() "type": "Person", "inbox": "https://example.com/actor/inbox", "outbox": "https://example.com/actor/outbox", + "sharedInbox": "https://example.com/actor/shared_inbox", "image": { "type": "Image" }, @@ -60,6 +61,7 @@ public void ShouldIncludePropertiesFromBaseTypes() var personUnderTest = ObjectUnderTest.As(); personUnderTest.Inbox.HRef.Should().Be("https://example.com/actor/inbox"); personUnderTest.Outbox.HRef.Should().Be("https://example.com/actor/outbox"); + personUnderTest.SharedInbox?.HRef.Should().Be("https://example.com/actor/shared_inbox"); personUnderTest.Image.Should().NotBeNull(); personUnderTest.Id.Should().Be("https://example.com/actor/id"); } diff --git a/Test/ActivityPub.Types.Tests/Integration/Serialization/SimpleObjectSerializationTests.cs b/Test/ActivityPub.Types.Tests/Integration/Serialization/SimpleObjectSerializationTests.cs index 3605b90..f334e35 100644 --- a/Test/ActivityPub.Types.Tests/Integration/Serialization/SimpleObjectSerializationTests.cs +++ b/Test/ActivityPub.Types.Tests/Integration/Serialization/SimpleObjectSerializationTests.cs @@ -71,6 +71,7 @@ public void ShouldIncludePropertiesFromBaseTypes() // From APActor Inbox = "https://example.com/actor/inbox", Outbox = "https://example.com/actor/outbox", + SharedInbox = "https://example.com/actor/shared_inbox", // From ASObject Image = new ImageObject(), From 6dd7275c960b5bcff1593792786b27b81eaca7e8 Mon Sep 17 00:00:00 2001 From: Hazel K Date: Wed, 16 Oct 2024 09:08:01 -0400 Subject: [PATCH 2/2] chore: fix collection formatting --- Source/ActivityPub.Types/AS/Collection/ASCollection.cs | 1 + .../ActivityPub.Types/AS/Collection/ASOrderedCollection.cs | 2 +- .../AS/Collection/ASOrderedCollectionPage.cs | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/ActivityPub.Types/AS/Collection/ASCollection.cs b/Source/ActivityPub.Types/AS/Collection/ASCollection.cs index a30ff91..10a240f 100644 --- a/Source/ActivityPub.Types/AS/Collection/ASCollection.cs +++ b/Source/ActivityPub.Types/AS/Collection/ASCollection.cs @@ -46,6 +46,7 @@ public ASCollection(TypeMap typeMap, ASCollectionEntity? entity) : base(typeMap, static ASCollection IASModel.FromGraph(TypeMap typeMap) => new(typeMap, null); private ASCollectionEntity Entity { get; } + /// /// In a paged Collection, indicates the page that contains the most recently updated member items. diff --git a/Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs b/Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs index 9b4c8d7..b228b66 100644 --- a/Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs +++ b/Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs @@ -46,7 +46,7 @@ public ASOrderedCollection(TypeMap typeMap, ASOrderedCollectionEntity? entity) : static ASOrderedCollection IASModel.FromGraph(TypeMap typeMap) => new(typeMap, null); private ASOrderedCollectionEntity Entity { get; } - + /// /// In a paged Collection, indicates the page that contains the most recently updated member items. diff --git a/Source/ActivityPub.Types/AS/Collection/ASOrderedCollectionPage.cs b/Source/ActivityPub.Types/AS/Collection/ASOrderedCollectionPage.cs index a4f90e5..94ad48b 100644 --- a/Source/ActivityPub.Types/AS/Collection/ASOrderedCollectionPage.cs +++ b/Source/ActivityPub.Types/AS/Collection/ASOrderedCollectionPage.cs @@ -89,7 +89,10 @@ public int? StartIndex /// /// Converts a list of objects into an ordered collection page. /// - public static implicit operator ASOrderedCollectionPage(List collection) => new() { Items = new LinkableList(collection) }; + public static implicit operator ASOrderedCollectionPage(List collection) => new() + { + Items = new LinkableList(collection) + }; } ///