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

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

Open
TheNoim opened this issue Mar 4, 2025 · 0 comments
Open

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

TheNoim opened this issue Mar 4, 2025 · 0 comments

Comments

@TheNoim
Copy link

TheNoim commented Mar 4, 2025

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"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant