From 47a07d37f3c89a04e4209063a20035540dff9a90 Mon Sep 17 00:00:00 2001 From: okayurisotto Date: Sun, 2 Jul 2023 13:39:13 +0900 Subject: [PATCH] refactor(`ApNoteService.ts`): non-null assertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit これまでは`getApId()`の方でエラーがスローされていた。 --- .../backend/src/core/activitypub/models/ApNoteService.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/activitypub/models/ApNoteService.ts b/packages/backend/src/core/activitypub/models/ApNoteService.ts index de9f977840..b82e577dfd 100644 --- a/packages/backend/src/core/activitypub/models/ApNoteService.ts +++ b/packages/backend/src/core/activitypub/models/ApNoteService.ts @@ -140,7 +140,11 @@ export class ApNoteService { this.logger.info(`Creating the Note: ${note.id}`); // 投稿者をフェッチ - const actor = await this.apPersonService.resolvePerson(getOneApId(note.attributedTo!), resolver) as RemoteUser; + if (note.attributedTo == null) { + throw new Error('invalid note.attributedTo: ' + note.attributedTo); + } + + const actor = await this.apPersonService.resolvePerson(getOneApId(note.attributedTo), resolver) as RemoteUser; // 投稿者が凍結されていたらスキップ if (actor.isSuspended) {