mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-11-27 14:28:53 +09:00
Merge pull request #75 from caipira113/develop
fix(backend): Resolve issue with UserGroupInvitation in notifications
This commit is contained in:
commit
3d9d727d0b
@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||
import { ModuleRef } from '@nestjs/core';
|
||||
import { In } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { AccessTokensRepository, FollowRequestsRepository, NoteReactionsRepository, NotesRepository, User, UsersRepository } from '@/models/index.js';
|
||||
import type { AccessTokensRepository, FollowRequestsRepository, NoteReactionsRepository, NotesRepository, User, UsersRepository, UserGroupInvitationsRepository } from '@/models/index.js';
|
||||
import { awaitAll } from '@/misc/prelude/await-all.js';
|
||||
import type { Notification } from '@/models/entities/Notification.js';
|
||||
import type { Note } from '@/models/entities/Note.js';
|
||||
@ -43,6 +43,9 @@ export class NotificationEntityService implements OnModuleInit {
|
||||
@Inject(DI.accessTokensRepository)
|
||||
private accessTokensRepository: AccessTokensRepository,
|
||||
|
||||
@Inject(DI.userGroupInvitationsRepository)
|
||||
private userGroupInvitationsRepository: UserGroupInvitationsRepository,
|
||||
|
||||
//private userEntityService: UserEntityService,
|
||||
//private noteEntityService: NoteEntityService,
|
||||
//private userGroupInvitationEntityService: UserGroupInvitationEntityService,
|
||||
@ -156,6 +159,14 @@ export class NotificationEntityService implements OnModuleInit {
|
||||
validNotifications = validNotifications.filter(x => (x.type !== 'receiveFollowRequest') || reqs.some(r => r.followerId === x.notifierId));
|
||||
}
|
||||
|
||||
const groupInvitedNotifications = validNotifications.filter(x => x.type === 'groupInvited');
|
||||
if (groupInvitedNotifications.length > 0) {
|
||||
const existingInvitationIds = await this.userGroupInvitationsRepository.find({
|
||||
where: { id: In(groupInvitedNotifications.map(x => x.userGroupInvitationId!)) },
|
||||
});
|
||||
validNotifications = validNotifications.filter(x => (x.type !== 'groupInvited') || existingInvitationIds.some(r => r.id === x.userGroupInvitationId));
|
||||
}
|
||||
|
||||
return await Promise.all(validNotifications.map(x => this.pack(x, meId, {}, {
|
||||
packedNotes,
|
||||
packedUsers,
|
||||
|
Loading…
Reference in New Issue
Block a user