activitypub: fix LD context
Some checks failed
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/test Pipeline failed

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 21ab8e75ee, thanks to sn0w.
This commit is contained in:
Johann150 2024-05-13 00:30:00 +02:00
parent a9c6e51051
commit be950f5313
Signed by: Johann150
GPG key ID: 9EE6577A2A06F8F1
2 changed files with 12 additions and 7 deletions

View file

@ -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': {

View file

@ -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,
});
}