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

Refactor ActivityStreams collections #1242

Merged
merged 20 commits into from
Apr 19, 2024
Merged

Refactor ActivityStreams collections #1242

merged 20 commits into from
Apr 19, 2024

Conversation

srosset81
Copy link
Contributor

@srosset81 srosset81 commented Apr 1, 2024

Close #1166
Close #1165
Close #1232

  • Create a /as/collection container and put all collections in it
  • Allow to create collections by POSTing to this new container
  • Persist collections options: itemsPerPage, dereferenceItems, sortPredicate and sortOrder (see Refactor collections creation #1166)
  • Allow to add or remove items from collections with a SPARQL Update
  • Simplify the CollectionsRegistryService to only automate the creation of collections
  • Add an ActivitypubApiService to handle POST to inbox and outbox routes
  • Remove the ControlledCollectionMixin (not needed anymore by the InboxService and OutboxService)
  • Improve local JSON-LD context by putting all prefixes at the beginning
  • Replace deleted objects with Tombstones (Create a Tombstone for every deleted resource #1232)
  • Refactor ReplyService and LikeService so that /replies and /likes collections are only created when required (this allows to use these functionnalities with any kind of object)
  • Tests for the new collection API

Breaking changes ⚠️

AS collections are now handled like regular LDP resources, except the get, post and patch actions are modified through the ControlledContainerMixin (and the put action is forbidden). The ActivitypubCollectionService has thus many changes to its actions:

  • The create action has been removed. Collections should be created by POSTing them to the collections container.
  • The get and exist actions now take a resourceUri parameter instead of collectionUri.
  • The attach action has been renamed add (attach is used to attach a resource to a container)
  • The detach action has been renamed remove (detach is used to detach a resource from a container)

By default, the ActivitypubObjectService replaces deleted objects with Tombstones. This allows other servers to know what was the type of a deleted resource. If you don't want to enable this usage, you can pass activateTombstones: false to the ActivitypubService (or activitypub: { activateTombstones: false } to the CoreService).

The /likes and /replies collections are only attached to objects when items are added to them. So you should not assume these collections exist in your frontend code.

Migration

Import the ActivityPubMigrationService from the @semapps/activitypub package, and enter these commands in Moleculer REPL:

call activitypub.migration.updateCollectionsOptions
call activitypub.migration.addCollectionsToContainer

If you have created custom collections, you will need to persist the options as well. To do that, you can call the activitypub.collections-registry.updateCollectionsOptions, passing the collection options in the collection param.

@srosset81 srosset81 marked this pull request as ready for review April 18, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant