Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sharedInbox to Actor #176

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Source/ActivityPub.Types/AS/APActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ public required ASLink Outbox
set => Entity.Outbox = value;
}

/// <summary>
/// An optional endpoint used for wide delivery of activities addressed to public or other collections
/// </summary>
public ASLink? SharedInbox
{
get => Entity.SharedInbox;
set => Entity.SharedInbox = value;
}

/// <summary>
/// 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.
Expand Down Expand Up @@ -155,6 +164,10 @@ public sealed class APActorEntity : ASEntity<APActor, APActorEntity>
/// <inheritdoc cref="APActor.Outbox" />
[JsonPropertyName("outbox")]
public ASLink? Outbox { get; set; }

/// <inheritdoc cref="APActor.SharedInbox"/>
[JsonPropertyName("sharedInbox")]
public ASLink? SharedInbox { get; set; }

/// <inheritdoc cref="APActor.Following" />
[JsonPropertyName("following")]
Expand Down
1 change: 1 addition & 0 deletions Source/ActivityPub.Types/AS/Collection/ASCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public ASCollection(TypeMap typeMap, ASCollectionEntity? entity) : base(typeMap,
static ASCollection IASModel<ASCollection>.FromGraph(TypeMap typeMap) => new(typeMap, null);

private ASCollectionEntity Entity { get; }


/// <summary>
/// In a paged Collection, indicates the page that contains the most recently updated member items.
Expand Down
4 changes: 2 additions & 2 deletions Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/// </remarks>
/// <seealso href="https://www.w3.org/TR/activitystreams-vocabulary/#dfn-collection" />
/// <seealso href="https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollection" />
public class ASOrderedCollection : ASObject, IASModel<ASOrderedCollection, ASOrderedCollectionEntity, ASObject>, IEnumerable<Linkable<ASObject>>
public class ASOrderedCollection : ASCollection, IASModel<ASOrderedCollection, ASOrderedCollectionEntity, ASCollection>, IEnumerable<Linkable<ASObject>>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this, unfortunately, won't work because ASCollection has a separate entity with a separate copy of the collection. It may be possible to support this by loading the same entity into both classes - I'll take a look into that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not that big of a deal, honestly. I'll split out the shared inbox. The rest is workable as-is. The AS2 inheritance tree is nonsensical.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it also breaks for ASOrderedCollectionPage, which should logically be assignable to both ASOrderedCollection and ASCollectionPage

{
/// <summary>
/// ActivityStreams type name for "OrderedCollection" types.
Expand All @@ -46,13 +46,13 @@
static ASOrderedCollection IASModel<ASOrderedCollection>.FromGraph(TypeMap typeMap) => new(typeMap, null);

private ASOrderedCollectionEntity Entity { get; }


/// <summary>
/// In a paged Collection, indicates the page that contains the most recently updated member items.
/// </summary>
/// <seealso href="https://www.w3.org/TR/activitystreams-vocabulary/#dfn-current" />
public Linkable<ASOrderedCollectionPage>? Current

Check warning on line 55 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, ubuntu-latest)

'ASOrderedCollection.Current' hides inherited member 'ASCollection.Current'. Use the new keyword if hiding was intended.

Check warning on line 55 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, ubuntu-latest)

'ASOrderedCollection.Current' hides inherited member 'ASCollection.Current'. Use the new keyword if hiding was intended.

Check warning on line 55 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, windows-latest)

'ASOrderedCollection.Current' hides inherited member 'ASCollection.Current'. Use the new keyword if hiding was intended.

Check warning on line 55 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, windows-latest)

'ASOrderedCollection.Current' hides inherited member 'ASCollection.Current'. Use the new keyword if hiding was intended.

Check warning on line 55 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, macos-latest)

'ASOrderedCollection.Current' hides inherited member 'ASCollection.Current'. Use the new keyword if hiding was intended.

Check warning on line 55 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, macos-latest)

'ASOrderedCollection.Current' hides inherited member 'ASCollection.Current'. Use the new keyword if hiding was intended.
{
get => Entity.Current;
set => Entity.Current = value;
Expand All @@ -62,7 +62,7 @@
/// In a paged Collection, indicates the furthest preceding page of items in the collection.
/// </summary>
/// <seealso href="https://www.w3.org/TR/activitystreams-vocabulary/#dfn-first" />
public Linkable<ASOrderedCollectionPage>? First

Check warning on line 65 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, ubuntu-latest)

'ASOrderedCollection.First' hides inherited member 'ASCollection.First'. Use the new keyword if hiding was intended.

Check warning on line 65 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, windows-latest)

'ASOrderedCollection.First' hides inherited member 'ASCollection.First'. Use the new keyword if hiding was intended.

Check warning on line 65 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, macos-latest)

'ASOrderedCollection.First' hides inherited member 'ASCollection.First'. Use the new keyword if hiding was intended.
{
get => Entity.First;
set => Entity.First = value;
Expand All @@ -72,7 +72,7 @@
/// In a paged Collection, indicates the furthest proceeding page of the collection.
/// </summary>
/// <seealso href="https://www.w3.org/TR/activitystreams-vocabulary/#dfn-last" />
public Linkable<ASOrderedCollectionPage>? Last

Check warning on line 75 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, ubuntu-latest)

'ASOrderedCollection.Last' hides inherited member 'ASCollection.Last'. Use the new keyword if hiding was intended.

Check warning on line 75 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, windows-latest)

'ASOrderedCollection.Last' hides inherited member 'ASCollection.Last'. Use the new keyword if hiding was intended.

Check warning on line 75 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, macos-latest)

'ASOrderedCollection.Last' hides inherited member 'ASCollection.Last'. Use the new keyword if hiding was intended.
{
get => Entity.Last;
set => Entity.Last = value;
Expand All @@ -88,7 +88,7 @@
/// If neither is set, returns zero.
/// This cannot be set to less than zero.
/// </remarks>
public int TotalItems

Check warning on line 91 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, ubuntu-latest)

'ASOrderedCollection.TotalItems' hides inherited member 'ASCollection.TotalItems'. Use the new keyword if hiding was intended.

Check warning on line 91 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, windows-latest)

'ASOrderedCollection.TotalItems' hides inherited member 'ASCollection.TotalItems'. Use the new keyword if hiding was intended.

Check warning on line 91 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, macos-latest)

'ASOrderedCollection.TotalItems' hides inherited member 'ASCollection.TotalItems'. Use the new keyword if hiding was intended.
{
get => Entity.TotalItems;
set => Entity.TotalItems = value;
Expand All @@ -104,7 +104,7 @@
/// In a paged collection, this MAY be null
/// </remarks>
/// <seealso href="https://www.w3.org/TR/activitystreams-vocabulary/#dfn-items" />
public LinkableList<ASObject>? Items

Check warning on line 107 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, ubuntu-latest)

'ASOrderedCollection.Items' hides inherited member 'ASCollection.Items'. Use the new keyword if hiding was intended.

Check warning on line 107 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, windows-latest)

'ASOrderedCollection.Items' hides inherited member 'ASCollection.Items'. Use the new keyword if hiding was intended.

Check warning on line 107 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, macos-latest)

'ASOrderedCollection.Items' hides inherited member 'ASCollection.Items'. Use the new keyword if hiding was intended.
{
get => Entity.Items;
set => Entity.Items = value;
Expand All @@ -114,18 +114,18 @@
/// True if this is a paged collection, false otherwise.
/// </summary>
[MemberNotNullWhen(true, nameof(FirstPopulated))]
public bool IsPaged => Current != null || First != null || Last != null;

Check warning on line 117 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, ubuntu-latest)

'ASOrderedCollection.IsPaged' hides inherited member 'ASCollection.IsPaged'. Use the new keyword if hiding was intended.

Check warning on line 117 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, windows-latest)

'ASOrderedCollection.IsPaged' hides inherited member 'ASCollection.IsPaged'. Use the new keyword if hiding was intended.

Check warning on line 117 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, macos-latest)

'ASOrderedCollection.IsPaged' hides inherited member 'ASCollection.IsPaged'. Use the new keyword if hiding was intended.

/// <summary>
/// In a paged Collection, gets the first populated entity.
/// </summary>
public Linkable<ASOrderedCollectionPage>? FirstPopulated => Current ?? First ?? Last;

Check warning on line 122 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, ubuntu-latest)

'ASOrderedCollection.FirstPopulated' hides inherited member 'ASCollection.FirstPopulated'. Use the new keyword if hiding was intended.

Check warning on line 122 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, windows-latest)

'ASOrderedCollection.FirstPopulated' hides inherited member 'ASCollection.FirstPopulated'. Use the new keyword if hiding was intended.

Check warning on line 122 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, macos-latest)

'ASOrderedCollection.FirstPopulated' hides inherited member 'ASCollection.FirstPopulated'. Use the new keyword if hiding was intended.

/// <summary>
/// True if this collection instance contains items, false otherwise.
/// </summary>
[MemberNotNullWhen(true, nameof(Items))]
public bool HasItems => Items?.Any() == true;

Check warning on line 128 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, ubuntu-latest)

'ASOrderedCollection.HasItems' hides inherited member 'ASCollection.HasItems'. Use the new keyword if hiding was intended.

Check warning on line 128 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, windows-latest)

'ASOrderedCollection.HasItems' hides inherited member 'ASCollection.HasItems'. Use the new keyword if hiding was intended.

Check warning on line 128 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, macos-latest)

'ASOrderedCollection.HasItems' hides inherited member 'ASCollection.HasItems'. Use the new keyword if hiding was intended.

/// <summary>
/// Converts a list of items into an ordered collection.
Expand All @@ -136,7 +136,7 @@
};

/// <inheritdoc />
public IEnumerator<Linkable<ASObject>> GetEnumerator() => Items?.GetEnumerator() ?? Enumerable.Empty<Linkable<ASObject>>().GetEnumerator();

Check warning on line 139 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, ubuntu-latest)

'ASOrderedCollection.GetEnumerator()' hides inherited member 'ASCollection.GetEnumerator()'. Use the new keyword if hiding was intended.

Check warning on line 139 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, windows-latest)

'ASOrderedCollection.GetEnumerator()' hides inherited member 'ASCollection.GetEnumerator()'. Use the new keyword if hiding was intended.

Check warning on line 139 in Source/ActivityPub.Types/AS/Collection/ASOrderedCollection.cs

View workflow job for this annotation

GitHub Actions / build (8.0.x, macos-latest)

'ASOrderedCollection.GetEnumerator()' hides inherited member 'ASCollection.GetEnumerator()'. Use the new keyword if hiding was intended.

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ public int? StartIndex
/// <summary>
/// Converts a list of objects into an ordered collection page.
/// </summary>
public static implicit operator ASOrderedCollectionPage(List<ASObject> collection) => new() { Items = new LinkableList<ASObject>(collection) };
public static implicit operator ASOrderedCollectionPage(List<ASObject> collection) => new()
{
Items = new LinkableList<ASObject>(collection)
};
}

/// <inheritdoc cref="ASOrderedCollectionPage" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -60,6 +61,7 @@ public void ShouldIncludePropertiesFromBaseTypes()
var personUnderTest = ObjectUnderTest.As<PersonActor>();
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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Loading