From 3693ce9f00b3fbfecd76f7c1d33a9d4745b3619d Mon Sep 17 00:00:00 2001
From: taichan <dev@taichan.site>
Date: Tue, 20 Feb 2024 15:21:23 +0900
Subject: [PATCH] Improve performance

---
 .../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 886a9e288d..26287ea544 100644
--- a/packages/backend/src/core/entities/NotificationEntityService.ts
+++ b/packages/backend/src/core/entities/NotificationEntityService.ts
@@ -61,7 +61,7 @@ export class NotificationEntityService implements OnModuleInit {
 		meId: MiUser['id'],
 		// eslint-disable-next-line @typescript-eslint/ban-types
 		options: {
-
+			checkValidNotifier?: boolean;
 		},
 		hint?: {
 			packedNotes: Map<MiNote['id'], Packed<'Note'>>;
@@ -70,7 +70,7 @@ export class NotificationEntityService implements OnModuleInit {
 	): Promise<Packed<'Notification'>|null> {
 		const notification = src;
 
-		if (!(await this.#isValidNotifier(notification, meId))) return null;
+		if (options.checkValidNotifier && !(await this.#isValidNotifier(notification, meId))) return null;
 
 		const noteIfNeed = NOTE_REQUIRED_NOTIFICATION_TYPES.has(notification.type) && 'noteId' in notification ? (
 			hint?.packedNotes != null
@@ -149,7 +149,7 @@ export class NotificationEntityService implements OnModuleInit {
 			validNotifications = validNotifications.filter(x => (x.type !== 'receiveFollowRequest') || reqs.some(r => r.followerId === x.notifierId));
 		}
 
-		return (await Promise.all(validNotifications.map(x => this.pack(x, meId, {}, {
+		return (await Promise.all(validNotifications.map(x => this.pack(x, meId, { checkValidNotifier: false }, {
 			packedNotes,
 			packedUsers,
 		})))).filter(isNotNull);
@@ -290,7 +290,7 @@ export class NotificationEntityService implements OnModuleInit {
 			validNotifications = validNotifications.filter(x => (x.type !== 'receiveFollowRequest') || reqs.some(r => r.followerId === x.notifierId));
 		}
 
-		return (await Promise.all(validNotifications.map(x => this.packGrouped(x, meId, {}, {
+		return (await Promise.all(validNotifications.map(x => this.packGrouped(x, meId, { checkValidNotifier: false }, {
 			packedNotes,
 			packedUsers,
 		})))).filter(isNotNull);