2024-07-01 12:27:33 +02:00
|
|
|
import { RequestHandler } from "express";
|
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
|
|
import { getInventory } from "@/src/services/inventoryService";
|
|
|
|
import { ITaunt } from "@/src/types/inventoryTypes/inventoryTypes";
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
|
|
export const tauntHistoryController: RequestHandler = async (req, res) => {
|
|
|
|
const accountId = await getAccountIdForRequest(req);
|
|
|
|
const inventory = await getInventory(accountId);
|
2024-09-03 20:21:09 +03:00
|
|
|
if (req.body !== undefined) {
|
2024-09-03 17:23:42 +03:00
|
|
|
const clientTaunt = JSON.parse(String(req.body)) as ITaunt;
|
|
|
|
inventory.TauntHistory ??= [];
|
2024-09-07 23:32:59 +03:00
|
|
|
inventory.TauntHistory.push(clientTaunt);
|
2024-09-03 17:23:42 +03:00
|
|
|
await inventory.save();
|
|
|
|
res.end();
|
2024-09-03 20:21:09 +03:00
|
|
|
} else {
|
2024-09-03 17:23:42 +03:00
|
|
|
res.json({});
|
2024-07-01 12:27:33 +02:00
|
|
|
}
|
|
|
|
};
|