From d0e00c8d17057fcdf510d102fc2a79c69aa8fe32 Mon Sep 17 00:00:00 2001 From: okayurisotto Date: Mon, 3 Jul 2023 07:15:09 +0900 Subject: [PATCH] =?UTF-8?q?WIP(`ApQuestionService.ts`):=20non-null=20asser?= =?UTF-8?q?tion=E3=82=92=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit エラーメッセージを考える必要がある。 --- .../backend/src/core/activitypub/models/ApQuestionService.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/activitypub/models/ApQuestionService.ts b/packages/backend/src/core/activitypub/models/ApQuestionService.ts index e3ded452cf..c5cec5a396 100644 --- a/packages/backend/src/core/activitypub/models/ApQuestionService.ts +++ b/packages/backend/src/core/activitypub/models/ApQuestionService.ts @@ -91,12 +91,14 @@ export class ApQuestionService { if (question.type !== 'Question') throw new Error('object is not a Question'); const apChoices = question.oneOf ?? question.anyOf; + if (apChoices == null) throw new Error(''); // TODO let changed = false; for (const choice of poll.choices) { const oldCount = poll.votes[poll.choices.indexOf(choice)]; - const newCount = apChoices!.filter(ap => ap.name === choice)[0].replies!.totalItems; + const newCount = apChoices.filter(ap => ap.name === choice).at(0)?.replies?.totalItems; + if (newCount == null) throw new Error(''); // TODO if (oldCount !== newCount) { changed = true;