From be950f531372639ecfe4a11090d7aebd4f42cf7a Mon Sep 17 00:00:00 2001 From: Johann150 Date: Mon, 13 May 2024 00:30:00 +0200 Subject: [PATCH] activitypub: fix LD context ActivityPub through ActivityStreams 2.0 requires the use of the expansion algorithm from JSON-LD 1.0 which is not able to handle nested contexts. Fixes commit 21ab8e75ee19a4f70f5a91d8613e1b1c873cc251, thanks to sn0w. --- .../backend/src/remote/activitypub/renderer/index.ts | 9 ++------- .../backend/src/remote/activitypub/renderer/person.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/backend/src/remote/activitypub/renderer/index.ts b/packages/backend/src/remote/activitypub/renderer/index.ts index 5c6679181..e99bbf2f8 100644 --- a/packages/backend/src/remote/activitypub/renderer/index.ts +++ b/packages/backend/src/remote/activitypub/renderer/index.ts @@ -46,13 +46,8 @@ export const renderActivity = (x: any): IActivity | null => { }, // schema schema: 'http://schema.org/', - PropertyValue: { - '@id': 'schema:PropertyValue', - '@context': { - 'value': 'schema:value', - 'name': 'schema:name', - }, - }, + PropertyValue: 'schema:PropertyValue', + value: 'schema:value', // Misskey misskey: 'https://misskey-hub.net/ns#', '_misskey_quote': { diff --git a/packages/backend/src/remote/activitypub/renderer/person.ts b/packages/backend/src/remote/activitypub/renderer/person.ts index 68f813aa8..dd6562e78 100644 --- a/packages/backend/src/remote/activitypub/renderer/person.ts +++ b/packages/backend/src/remote/activitypub/renderer/person.ts @@ -24,6 +24,7 @@ export async function renderPerson(user: ILocalUser) { const attachment: { type: 'PropertyValue', name: string, + 'schema:name': string, value: string, identifier?: IIdentifier }[] = []; @@ -44,6 +45,15 @@ export async function renderPerson(user: ILocalUser) { attachment.push({ type: 'PropertyValue', name: field.name, + // uses "name" for backward compatibility, but JSON-LD-expanding + // it ends up being the ActivityPub name property, which is not + // correct for this type. which is why we also send the "correct" + // schema.org name property field, which would not be recognized + // by people just processing JSON-LD as JSON as allowed by the spec. + // it would be nicer to do this with JSON-LD context, but this is + // only possible when using JSON-LD 1.1 with nested contexts, but + // activitystreams 2.0 requires the JSON-LD 1.0 expansion algorithm. + 'schema:name': field.name, value, }); }