From 21ab8e75ee19a4f70f5a91d8613e1b1c873cc251 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Tue, 30 May 2023 17:53:50 +0200 Subject: [PATCH] activitypub: improve JSON-LD context Added @type values for most definitions, and made name and value only scoped to the PropertyValue type. (Blame Volpeon) --- .../src/remote/activitypub/renderer/index.ts | 53 ++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/packages/backend/src/remote/activitypub/renderer/index.ts b/packages/backend/src/remote/activitypub/renderer/index.ts index b66f766a2..5c6679181 100644 --- a/packages/backend/src/remote/activitypub/renderer/index.ts +++ b/packages/backend/src/remote/activitypub/renderer/index.ts @@ -17,27 +17,56 @@ export const renderActivity = (x: any): IActivity | null => { 'https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1', { + xsd: 'http://www.w3.org/2001/XMLSchema#', // as non-standards - manuallyApprovesFollowers: 'as:manuallyApprovesFollowers', - sensitive: 'as:sensitive', + manuallyApprovesFollowers: { + '@id': 'as:manuallyApprovesFollowers', + '@type': 'xsd:boolean', + }, + sensitive: { + '@id': 'as:sensitive', + '@type': 'xsd:boolean', + }, Hashtag: 'as:Hashtag', // Mastodon toot: 'http://joinmastodon.org/ns#', Emoji: 'toot:Emoji', - featured: 'toot:featured', - discoverable: 'toot:discoverable', + featured: { + '@id': 'toot:featured', + '@type': '@id', + }, + discoverable: { + '@id': 'toot:discoverable', + '@type': 'xsd:boolean', + }, // Fedibird - fedibird: 'http://fedibird.com/ns#', - quoteUri: 'fedibird:quoteUri', + quoteUri: { + '@id': 'http://fedibird.com/ns#quoteUri', + '@type': '@id', + }, // schema - schema: 'http://schema.org#', - PropertyValue: 'schema:PropertyValue', - value: 'schema:value', + schema: 'http://schema.org/', + PropertyValue: { + '@id': 'schema:PropertyValue', + '@context': { + 'value': 'schema:value', + 'name': 'schema:name', + }, + }, // Misskey misskey: 'https://misskey-hub.net/ns#', - '_misskey_quote': 'misskey:_misskey_quote', - '_misskey_talk': 'misskey:_misskey_talk', - 'isCat': 'misskey:isCat', + '_misskey_quote': { + '@id': 'misskey:_misskey_quote', + '@type': '@id', + }, + '_misskey_talk': { + '@id': 'misskey:_misskey_talk', + '@type': 'xsd:boolean', + }, + 'isCat': { + '@id': 'misskey:isCat', + '@type': 'xsd:boolean', + }, // vcard vcard: 'http://www.w3.org/2006/vcard/ns#', },