[go: up one dir, main page]

Skip to content

Add releases actor's profile and outbox

Why are we doing this work

This is the first step needed to implement ActivityPub support, which will ultimately be used to allow cross-instance merge requests.

As the very first actor implemented, this one requires more careful work than the other will need, as it is also about building the foundations on which all other features will be implemented.

As all actors, it requires:

  • a profile page, where the actor provides basic data and links to outbox and inbox
  • an outbox, listing the various activities for the actor

In this case, the actor is the releases list for a project, and activities are the creation of a new release.

Profile

The profile in this actor is a bit different from others, because it's not that we want to show activities for a given release, what we want instead is releases for a given project.

So the profile endpoint is handled by Projects::ReleasesController#index, on the list of releases, and should reply with something like this:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "id": PROJECT_RELEASES_URL,
  "type": "Application",
  "name": PROJECT_NAME + " releases",
  "url": PROJECT_RELEASES_URL,
  "content": PROJECT_DESCRIPTION,
  "context": {
    "id": PROJECT_URL,
    "type": "Application",
    "name": PROJECT_NAME,
    "summary": PROJECT_DESCRIPTION,
    "url": PROJECT_URL,
  },
  "outbox": PROJECT_RELEASES_OUTBOX_URL,
  "inbox": null,
}

Outbox

The release actor will be fairly simple: the only activity happening is the "Create release" event.

{
  "id": PROJECT_RELEASES_OUTBOX_URL#release_id,
  "type": "Create",
  "to": [
    "https://www.w3.org/ns/activitystreams#Public"
  ],
  "actor": {
    "id": USER_PROFILE_URL,
    "type": "Person",
    "name": USER_NAME,
    "url": USER_PROFILE_URL,
  },
  "object": {
    "id": RELEASE_URL,
    "type": "Application",
    "name": RELEASE_TITLE,
    "url": RELEASE_URL,
    "content": RELEASE_DESCRIPTION,
    "context": {
      "id": PROJECT_URL,
      "type": "Application",
      "name": PROJECT_NAME,
      "summary": PROJECT_DESCRIPTION,
      "url": PROJECT_URL,
    },
  },
}

Relevant links

Non-functional requirements

  • Documentation:
  • Feature flag:
  • Testing:

Implementation plan

This is already implemented in !127023 (merged)

Verification steps

  1. make a few releases in a project
  2. make sure that project is public
  3. run the following to test the profile page, replacing flightjs/Flight with the fullpath of your project:
curl -H 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' http://127.0.0.1:3000/flightjs/Flight/-/releases
  1. run the following with similar edit to test the pagination index:
curl -H 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' http://127.0.0.1:3000/flightjs/Flight/-/releases/outbox
  1. run the following (samey) to test a pagination page:
curl -H 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' http://127.0.0.1:3000/flightjs/Flight/-/releases/outbox?page=1
  1. you can reproduce the same tests replacing Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams" with Accept: application/activity+json
Edited by kik