diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index e3c588a..23fc5d0 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -15,6 +15,7 @@ import { MoviesHelper } from "./MoviesHelper"; import { ConversationsHelper } from "./ConversationsHelper"; import { FriendsHelper } from "./FriendsHelper"; import { GroupsHelper } from "./GroupsHelper"; +import { NotificationsHelper } from "./NotificationsHelper"; /** * Account helper @@ -465,6 +466,9 @@ export class AccountHelper { // Remove the user from all its conversations await ConversationsHelper.DeleteAllUserConversations(userID); + + // Delete all the notifications related with the user + await NotificationsHelper.DeleteAllRelatedWithUser(userID); */ // TODO : continue work diff --git a/src/helpers/NotificationsHelper.ts b/src/helpers/NotificationsHelper.ts index 9ada9b5..0e3003b 100644 --- a/src/helpers/NotificationsHelper.ts +++ b/src/helpers/NotificationsHelper.ts @@ -282,6 +282,21 @@ export class NotificationsHelper { await this.Delete(n); } + /** + * Delete all the notifications related with a specified user + * + * @param userID Target user ID + */ + public static async DeleteAllRelatedWithUser(userID: number) { + // Delete all the notifications targetting the user + await this.DeleteAllUser(userID); + + // Delete all the notifications created by the user + await this.Delete(new Notif({ + fromUserID: userID + })); + } + /** * Count the number of unread notifications of a user *