summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-04-06 15:09:21 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-04-06 15:09:21 +0900
commitb38811af7c9952d15054f4aec6f81ea22dd290ca (patch)
tree797da6b53da850e48ad4886ee4680cbbf77b6191 /packages/backend/src
parentuse pnpm@8.1.1 (diff)
downloadsharkey-b38811af7c9952d15054f4aec6f81ea22dd290ca.tar.gz
sharkey-b38811af7c9952d15054f4aec6f81ea22dd290ca.tar.bz2
sharkey-b38811af7c9952d15054f4aec6f81ea22dd290ca.zip
fix(backend): fix pack of notification behaviour
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/entities/NotificationEntityService.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts
index 6b9a9d3320..1948cabad9 100644
--- a/packages/backend/src/core/entities/NotificationEntityService.ts
+++ b/packages/backend/src/core/entities/NotificationEntityService.ts
@@ -108,7 +108,9 @@ export class NotificationEntityService implements OnModuleInit {
) {
if (notifications.length === 0) return [];
- const noteIds = notifications.map(x => x.noteId).filter(isNotNull);
+ let validNotifications = notifications;
+
+ const noteIds = validNotifications.map(x => x.noteId).filter(isNotNull);
const notes = noteIds.length > 0 ? await this.notesRepository.find({
where: { id: In(noteIds) },
relations: ['user', 'user.avatar', 'user.banner', 'reply', 'reply.user', 'reply.user.avatar', 'reply.user.banner', 'renote', 'renote.user', 'renote.user.avatar', 'renote.user.banner'],
@@ -118,7 +120,9 @@ export class NotificationEntityService implements OnModuleInit {
});
const packedNotes = new Map(packedNotesArray.map(p => [p.id, p]));
- const userIds = notifications.map(x => x.notifierId).filter(isNotNull);
+ validNotifications = validNotifications.filter(x => x.noteId == null || packedNotes.has(x.noteId));
+
+ const userIds = validNotifications.map(x => x.notifierId).filter(isNotNull);
const users = userIds.length > 0 ? await this.usersRepository.find({
where: { id: In(userIds) },
relations: ['avatar', 'banner'],
@@ -128,7 +132,7 @@ export class NotificationEntityService implements OnModuleInit {
});
const packedUsers = new Map(packedUsersArray.map(p => [p.id, p]));
- return await Promise.all(notifications.map(x => this.pack(x, meId, {}, {
+ return await Promise.all(validNotifications.map(x => this.pack(x, meId, {}, {
packedNotes,
packedUsers,
})));