From 41f65a20f133352ee70ad0e828f4907e289e597b Mon Sep 17 00:00:00 2001 From: HinanoAira Date: Thu, 5 Sep 2024 23:34:41 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E9=80=9A=E7=9F=A5=E3=81=8B=E3=82=89?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=83=AB=E5=8F=82=E7=85=A7=E6=99=82=E3=81=AB?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=83=AB=E3=81=8C=E5=AD=98=E5=9C=A8=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=81=A8=E3=81=8D=E3=81=AE=E4=BE=8B=E5=A4=96?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/src/core/entities/NotificationEntityService.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index f393513510..c4ddb6efa8 100644 --- a/packages/backend/src/core/entities/NotificationEntityService.ts +++ b/packages/backend/src/core/entities/NotificationEntityService.ts @@ -59,7 +59,6 @@ export class NotificationEntityService implements OnModuleInit { async #packInternal ( src: T, meId: MiUser['id'], - // eslint-disable-next-line @typescript-eslint/ban-types options: { checkValidNotifier?: boolean; }, @@ -140,7 +139,10 @@ export class NotificationEntityService implements OnModuleInit { // #endregion const needsRole = notification.type === 'roleAssigned'; - const role = needsRole ? await this.roleEntityService.pack(notification.roleId) : undefined; + const role = needsRole ? await this.roleEntityService.pack(notification.roleId).catch((e) => { + if (e.name === 'EntityNotFoundError') return null; + throw e; + }) : undefined; // if the role has been deleted, don't show this notification if (needsRole && !role) { return null; @@ -229,7 +231,6 @@ export class NotificationEntityService implements OnModuleInit { public async pack( src: MiNotification | MiGroupedNotification, meId: MiUser['id'], - // eslint-disable-next-line @typescript-eslint/ban-types options: { checkValidNotifier?: boolean; }, From 8b0f3e7fa5a7f5e2e04b962f65631e9a48021b48 Mon Sep 17 00:00:00 2001 From: HinanoAira Date: Sun, 8 Sep 2024 04:11:22 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=8F?= =?UTF-8?q?=E3=83=B3=E3=83=89=E3=83=AA=E3=83=B3=E3=82=B0=E3=81=A7=E3=81=AE?= =?UTF-8?q?=E4=BF=9D=E5=AE=88=E6=80=A7=E3=81=AE=E7=A2=BA=E4=BF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - catchブロックでのeという変数名は混同の危険性があるため利用しない - 保守性のため型チェックでのエラーハンドリングを行う --- .../src/core/entities/NotificationEntityService.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index c4ddb6efa8..9bade830e2 100644 --- a/packages/backend/src/core/entities/NotificationEntityService.ts +++ b/packages/backend/src/core/entities/NotificationEntityService.ts @@ -5,7 +5,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { ModuleRef } from '@nestjs/core'; -import { In } from 'typeorm'; +import { EntityNotFoundError, In } from 'typeorm'; import { DI } from '@/di-symbols.js'; import type { FollowRequestsRepository, NotesRepository, MiUser, UsersRepository } from '@/models/_.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; @@ -139,9 +139,9 @@ export class NotificationEntityService implements OnModuleInit { // #endregion const needsRole = notification.type === 'roleAssigned'; - const role = needsRole ? await this.roleEntityService.pack(notification.roleId).catch((e) => { - if (e.name === 'EntityNotFoundError') return null; - throw e; + const role = needsRole ? await this.roleEntityService.pack(notification.roleId).catch((err) => { + if (err instanceof EntityNotFoundError) return null; + throw err; }) : undefined; // if the role has been deleted, don't show this notification if (needsRole && !role) {