bookwyrm-social / bookwyrm

Social reading and reviewing, decentralized with ActivityPub
http://joinbookwyrm.com/
Other
2.26k stars 266 forks source link

Mentioning user seems to generate invalid JSON-LD #2451

Closed indutny closed 1 year ago

indutny commented 1 year ago

Describe the bug

When sending a DM or mentioning a user on a custom ActivityPub server (not Maston, and not Bookwyrm) the generate JSON-LD which is being sent to the remote server's inbox contains Mention link that has "id":null, which is not valid according to JSON-LD playground:

{
  "id": "https://wyrms.de/user/indutny/status/28884/activity",
  "type": "Create",
  "actor": "https://wyrms.de/user/indutny",
  "object": {
    "id": "https://wyrms.de/user/indutny/status/28884",
    "type": "Note",
    "published": "2022-11-26T03:00:40.507496+00:00",
    "attributedTo": "https://wyrms.de/user/indutny",
    "content": "<p><a href=\"https://mean.engineer/users/test\">@test@mean.engineer</a> hm.</p>",
    "to": [
      "https://mean.engineer/users/test"
    ],
    "cc": [],
    "replies": {
      "id": "https://wyrms.de/user/indutny/status/28884/replies",
      "type": "OrderedCollection",
      "totalItems": 0,
      "first": "https://wyrms.de/user/indutny/status/28884/replies?page=1",
      "last": "https://wyrms.de/user/indutny/status/28884/replies?page=1",
      "@context": "https://www.w3.org/ns/activitystreams"
    },
    "tag": [
      {
        "id": null,
        "type": "Mention",
        "href": "https://mean.engineer/users/test",
        "name": "test@mean.engineer",
        "mediaType": null,
        "attributedTo": null,
        "availability": null
      }
    ],
    "attachment": [],
    "sensitive": false,
    "@context": "https://www.w3.org/ns/activitystreams"
  },
  "to": [
    "https://mean.engineer/users/test"
  ],
  "cc": [],
  "signature": {
    "creator": "https://wyrms.de/user/indutny#main-key",
    "created": "2022-11-26T03:00:40.507496+00:00",
    "signatureValue": "g8cUYgiFpRA7JOpcz0S6ejQaM3nseUYkqv7DjYJF/GzysnFzygJyBrOnR3yPGngIbOKf/eZorDcEPulebUIUZN499uY3G9D8jkxn3KMQa220Y+h4wqQh9qY87BeL2P47NKPvC/9f+Uc02Pm6iOojlxxtyrDcAY8mE/c18lpIlqI=",
    "type": "RsaSignature2017"
  },
  "@context": "https://www.w3.org/ns/activitystreams"
}

Note the "tag" field of the Note object above.

To Reproduce Steps to reproduce the behavior:

  1. Search for a user on remote server
  2. Send them a DM message

Expected behavior

DM message should be a valid JSON-LD object as per ActivityPub specifcation.

Screenshots

Not applicable.

Instance

https://wyrms.de/

Additional context

The error that I get from JSON-LD playground is:

jsonld.SyntaxError: Invalid JSON-LD syntax; "@id" value must a string.

indutny commented 1 year ago

I think what happens is that Link gets serialized without a call to serialize() method. I'm a total Python noob so not sure if I'll be able to fix it.

indutny commented 1 year ago

Ah, I think I actually know how to fix it!

indutny commented 1 year ago

Here goes the suggested fix: https://github.com/bookwyrm-social/bookwyrm/pull/2452