From 1d45bdbfdce91dc199a3ed26d77dd1779ec43ef8 Mon Sep 17 00:00:00 2001 From: Effy Elden Date: Wed, 4 Jan 2023 12:08:09 +1100 Subject: [PATCH 1/2] Support quotes provided as 'quoteUri' field --- packages/backend/src/remote/activitypub/models/note.ts | 4 ++-- packages/backend/src/remote/activitypub/type.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index 1c885e04d..ea74dddba 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -157,7 +157,7 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s // Quote let quote: Note | undefined | null; - if (note._misskey_quote || note.quoteUrl) { + if (note._misskey_quote || note.quoteUrl || note.quoteUri) { const tryResolveNote = async (uri: string): Promise<{ status: 'ok'; res: Note | null; @@ -184,7 +184,7 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s } }; - const uris = unique([note._misskey_quote, note.quoteUrl].filter((x): x is string => typeof x === 'string')); + const uris = unique([note._misskey_quote, note.quoteUrl, note.quoteUri].filter((x): x is string => typeof x === 'string')); const results = await Promise.all(uris.map(uri => tryResolveNote(uri))); quote = results.filter((x): x is { status: 'ok', res: Note | null } => x.status === 'ok').map(x => x.res).find(x => x); diff --git a/packages/backend/src/remote/activitypub/type.ts b/packages/backend/src/remote/activitypub/type.ts index aabbd0679..17920254f 100644 --- a/packages/backend/src/remote/activitypub/type.ts +++ b/packages/backend/src/remote/activitypub/type.ts @@ -112,6 +112,7 @@ export interface IPost extends IObject { }; _misskey_quote?: string; quoteUrl?: string; + quoteUri?: string; _misskey_talk: boolean; } From 94e4f1323fc9e2129f2bf9cdab0ac0f597f8ea41 Mon Sep 17 00:00:00 2001 From: Effy Elden Date: Wed, 4 Jan 2023 13:32:06 +1100 Subject: [PATCH 2/2] Set quoteUri in rendered ActivityPub objects --- packages/backend/src/remote/activitypub/renderer/index.ts | 1 + packages/backend/src/remote/activitypub/renderer/note.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/backend/src/remote/activitypub/renderer/index.ts b/packages/backend/src/remote/activitypub/renderer/index.ts index 2e1fbf1dd..6afdc021c 100644 --- a/packages/backend/src/remote/activitypub/renderer/index.ts +++ b/packages/backend/src/remote/activitypub/renderer/index.ts @@ -22,6 +22,7 @@ export const renderActivity = (x: any): IActivity | null => { movedToUri: 'as:movedTo', sensitive: 'as:sensitive', Hashtag: 'as:Hashtag', + quoteUri: 'fedibird:quoteUri', quoteUrl: 'as:quoteUrl', // Mastodon toot: 'http://joinmastodon.org/ns#', diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts index b3bafaa3a..83df0b10d 100644 --- a/packages/backend/src/remote/activitypub/renderer/note.ts +++ b/packages/backend/src/remote/activitypub/renderer/note.ts @@ -142,6 +142,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false mediaType: "text/x.misskeymarkdown", }, _misskey_quote: quote, + quoteUri: quote, quoteUrl: quote, published: note.createdAt.toISOString(), to,