From 535e0c69ce9ea182e48f2fcde0f35eb0ae6c6ab1 Mon Sep 17 00:00:00 2001 From: JeDaYoshi <hi@jeda.im> Date: Fri, 13 Dec 2024 16:46:34 -0400 Subject: [PATCH] Fix notifications breaking due to deleted role being assigned --- .../src/core/entities/NotificationEntityService.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index 31a9809323..cea674d96c 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 { In, EntityNotFoundError } 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'; @@ -140,7 +140,12 @@ 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(err => { + if (err instanceof EntityNotFoundError) return undefined; + throw err; + }) + : undefined; // if the role has been deleted, don't show this notification if (needsRole && !role) { return null; -- GitLab