fix: 通知からロール参照時にロールが存在しないときの例外処理を追加

This commit is contained in:
HinanoAira 2024-09-05 23:34:41 +09:00
parent 74c93fcebe
commit 41f65a20f1
No known key found for this signature in database
GPG Key ID: 7FBE088453C8B50C
1 changed files with 4 additions and 3 deletions

View File

@ -59,7 +59,6 @@ export class NotificationEntityService implements OnModuleInit {
async #packInternal <T extends MiNotification | MiGroupedNotification> (
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;
},