From ab576164836756f555901984ce5fa3b727ed31e3 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Fri, 22 Sep 2023 22:42:01 +0200 Subject: [PATCH] fix: AP Services throwing errors --- packages/backend/src/core/activitypub/ApMfmService.ts | 2 +- packages/backend/src/core/activitypub/ApRendererService.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/core/activitypub/ApMfmService.ts b/packages/backend/src/core/activitypub/ApMfmService.ts index 60868627a..c45c27f86 100644 --- a/packages/backend/src/core/activitypub/ApMfmService.ts +++ b/packages/backend/src/core/activitypub/ApMfmService.ts @@ -27,6 +27,6 @@ export class ApMfmService { @bindThis public getNoteHtml(note: MiNote): string | null { if (!note.text) return ''; - return this.mfmService.toHtml(mfm.parse(note.text), JSON.parse(note.mentionedRemoteUsers)); + return this.mfmService.toHtml(mfm.parse(note.text), note.mentionedRemoteUsers ? JSON.parse(note.mentionedRemoteUsers) : []); } } diff --git a/packages/backend/src/core/activitypub/ApRendererService.ts b/packages/backend/src/core/activitypub/ApRendererService.ts index 7a9d2e21d..b772f3efd 100644 --- a/packages/backend/src/core/activitypub/ApRendererService.ts +++ b/packages/backend/src/core/activitypub/ApRendererService.ts @@ -353,7 +353,7 @@ export class ApRendererService { const attributedTo = this.userEntityService.genLocalUserUri(note.userId); - const mentions = (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri); + const mentions = note.mentionedRemoteUsers ? (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri) : []; let to: string[] = []; let cc: string[] = []; @@ -371,7 +371,7 @@ export class ApRendererService { to = mentions; } - const mentionedUsers = note.mentions.length > 0 ? await this.usersRepository.findBy({ + const mentionedUsers = note.mentions && note.mentions.length > 0 ? await this.usersRepository.findBy({ id: In(note.mentions), }) : [];