mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-10 02:03:08 +02:00
fix(backend): fix pack of notification behaviour
This commit is contained in:
parent
bc5be83e29
commit
b38811af7c
1 changed files with 7 additions and 3 deletions
|
@ -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,
|
||||
})));
|
||||
|
|
Loading…
Reference in a new issue