From c234f3afe195650385963cccb912d4c364a81849 Mon Sep 17 00:00:00 2001 From: okayurisotto Date: Sun, 2 Jul 2023 13:56:13 +0900 Subject: [PATCH] =?UTF-8?q?refactor(`ApNoteService.ts`):=20=E3=82=88?= =?UTF-8?q?=E3=82=8A=E3=82=88=E3=81=84=E5=9E=8B=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `res`が`null`でないことは確認されているようだったので`null`とのunionはなくした --- .../src/core/activitypub/models/ApNoteService.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/backend/src/core/activitypub/models/ApNoteService.ts b/packages/backend/src/core/activitypub/models/ApNoteService.ts index f5df823d21..acfab3aadc 100644 --- a/packages/backend/src/core/activitypub/models/ApNoteService.ts +++ b/packages/backend/src/core/activitypub/models/ApNoteService.ts @@ -197,12 +197,10 @@ export class ApNoteService { let quote: Note | undefined | null; if (note._misskey_quote || note.quoteUrl) { - const tryResolveNote = async (uri: string): Promise<{ - status: 'ok'; - res: Note | null; - } | { - status: 'permerror' | 'temperror'; - }> => { + const tryResolveNote = async (uri: string): Promise< + | { status: 'ok'; res: Note } + | { status: 'permerror' | 'temperror' } + > => { if (typeof uri !== 'string' || !uri.match(/^https?:/)) return { status: 'permerror' }; try { const res = await this.resolveNote(uri); @@ -226,7 +224,7 @@ export class ApNoteService { const uris = unique([note._misskey_quote, note.quoteUrl].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); + quote = results.filter((x): x is { status: 'ok', res: Note } => x.status === 'ok').map(x => x.res).at(0); if (!quote) { if (results.some(x => x.status === 'temperror')) { throw new Error('quote resolve failed');