From 2f4b3e0d63f0bfc2950085586daedf096a7bf203 Mon Sep 17 00:00:00 2001 From: Sainan Date: Tue, 4 Feb 2025 21:36:18 +0100 Subject: [PATCH] fix: delete inbox messages when deleting account --- src/controllers/custom/deleteAccountController.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/controllers/custom/deleteAccountController.ts b/src/controllers/custom/deleteAccountController.ts index e2396379..643c2490 100644 --- a/src/controllers/custom/deleteAccountController.ts +++ b/src/controllers/custom/deleteAccountController.ts @@ -1,6 +1,7 @@ import { RequestHandler } from "express"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { Account } from "@/src/models/loginModel"; +import { Inbox } from "@/src/models/inboxModel"; import { Inventory } from "@/src/models/inventoryModels/inventoryModel"; import { Loadout } from "@/src/models/inventoryModels/loadoutModel"; import { PersonalRooms } from "@/src/models/personalRoomsModel"; @@ -10,6 +11,7 @@ export const deleteAccountController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); await Promise.all([ Account.deleteOne({ _id: accountId }), + Inbox.deleteMany({ ownerId: accountId }), Inventory.deleteOne({ accountOwnerId: accountId }), Loadout.deleteOne({ loadoutOwnerId: accountId }), PersonalRooms.deleteOne({ personalRoomsOwnerId: accountId }), -- 2.47.2