Skip to content

Activity allows string and string array for to and cc #104

@TheNoim

Description

@TheNoim

Hi,

I am currently in the process of implementing relay support in hollo. In the process of testing I noticed that this project doesn't accept spec conform Activity objects. After I added some logging to the relay software, I was able to pin it down to the Activity model.

json: cannot unmarshal string into Go struct field Activity.to of type []string

A single string is a valid value for to according to https://www.w3.org/TR/activitystreams-vocabulary/#dfn-to

The Activity Streams 2.0 Vocabulary defines the to property as having a range of Object. In JSON-LD, properties defined with a range of Object can accept either a single object or an array of objects. This means that the to property can be serialized as either a single IRI or an array of IRIs, depending on the context. This is why fedify implements it this way.\

An object like this should work just fine:

{
  "id": "https://example.com/@test/0195624c-6dc2-7fa2-9c26-62501ad5e14d",
  "to": "as:Public",
  "url": "https://example.com/@test/0195624c-6dc2-7fa2-9c26-62501ad5e14d",
  "type": "Note",
  "likes": {
    "id": "https://example.com/@test/0195624c-6dc2-7fa2-9c26-62501ad5e14d#likes",
    "type": "Collection",
    "totalItems": 0
  },
  "shares": {
    "id": "https://example.com/@test/0195624c-6dc2-7fa2-9c26-62501ad5e14d#shares",
    "type": "Collection",
    "totalItems": 0
  },
  "source": {
    "type": "as:Source",
    "content": "Test",
    "mediaType": "text/markdown"
  },
  "content": "<p>Test</p>\n",
  "replies": {
    "id": "https://example.com/@test/0195624c-6dc2-7fa2-9c26-62501ad5e14d#replies",
    "type": "OrderedCollection",
    "totalItems": 0
  },
  "published": "2025-03-04T17:55:30.895Z",
  "sensitive": false,
  "contentMap": {
    "en": "<p>Test</p>\n"
  },
  "attributedTo": "https://example.com/@test"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions