2024-12-23 03:34:14 +01:00
|
|
|
import { RequestHandler } from "express";
|
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
|
|
import { Account } from "@/src/models/loginModel";
|
2025-02-05 05:54:24 -08:00
|
|
|
import { Inbox } from "@/src/models/inboxModel";
|
2024-12-23 03:34:14 +01:00
|
|
|
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
|
|
|
import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
|
|
|
|
import { PersonalRooms } from "@/src/models/personalRoomsModel";
|
|
|
|
import { Ship } from "@/src/models/shipModel";
|
2025-02-06 04:42:59 -08:00
|
|
|
import { Stats } from "@/src/models/statsModel";
|
2025-03-10 16:40:40 -07:00
|
|
|
import { GuildMember } from "@/src/models/guildModel";
|
2024-12-23 03:34:14 +01:00
|
|
|
|
|
|
|
export const deleteAccountController: RequestHandler = async (req, res) => {
|
|
|
|
const accountId = await getAccountIdForRequest(req);
|
2025-03-10 16:40:40 -07:00
|
|
|
// TODO: Handle the account being the creator of a guild
|
2024-12-23 03:34:14 +01:00
|
|
|
await Promise.all([
|
|
|
|
Account.deleteOne({ _id: accountId }),
|
2025-03-22 18:12:59 -07:00
|
|
|
GuildMember.deleteMany({ accountId: accountId }),
|
2025-02-05 05:54:24 -08:00
|
|
|
Inbox.deleteMany({ ownerId: accountId }),
|
2024-12-23 03:34:14 +01:00
|
|
|
Inventory.deleteOne({ accountOwnerId: accountId }),
|
|
|
|
Loadout.deleteOne({ loadoutOwnerId: accountId }),
|
|
|
|
PersonalRooms.deleteOne({ personalRoomsOwnerId: accountId }),
|
2025-03-22 18:12:59 -07:00
|
|
|
Ship.deleteMany({ ShipOwnerId: accountId }),
|
2025-02-06 04:42:59 -08:00
|
|
|
Stats.deleteOne({ accountOwnerId: accountId })
|
2024-12-23 03:34:14 +01:00
|
|
|
]);
|
|
|
|
res.end();
|
|
|
|
};
|