chore: use updateOne for simple inventory field setters
All checks were successful
Build / build (18) (push) Successful in 45s
Build / build (22) (push) Successful in 1m5s
Build / build (20) (push) Successful in 1m2s
Build / build (18) (pull_request) Successful in 47s
Build / build (20) (pull_request) Successful in 1m7s
Build / build (22) (pull_request) Successful in 1m1s

This commit is contained in:
Sainan 2025-03-16 13:58:44 +01:00
parent c3a9b42fa2
commit d9eec90d3c
4 changed files with 38 additions and 19 deletions

View File

@ -1,16 +1,25 @@
import { RequestHandler } from "express";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { IUpdateGlyphRequest } from "@/src/types/requestTypes";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService";
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
const addFriendImageController: RequestHandler = async (req, res) => {
export const addFriendImageController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const json = getJSONfromString<IUpdateGlyphRequest>(String(req.body));
const inventory = await getInventory(accountId);
inventory.ActiveAvatarImageType = json.AvatarImageType;
await inventory.save();
await Inventory.updateOne(
{
accountOwnerId: accountId
},
{
ActiveAvatarImageType: json.AvatarImageType
}
);
res.json({});
};
export { addFriendImageController };
interface IUpdateGlyphRequest {
AvatarImageType: string;
AvatarImage: string;
}

View File

@ -1,14 +1,21 @@
import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
export const setEquippedInstrumentController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
const body = getJSONfromString<ISetEquippedInstrumentRequest>(String(req.body));
inventory.EquippedInstrument = body.Instrument;
await inventory.save();
await Inventory.updateOne(
{
accountOwnerId: accountId
},
{
EquippedInstrument: body.Instrument
}
);
res.end();
};

View File

@ -1,11 +1,18 @@
import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService";
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
export const setSupportedSyndicateController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
inventory.SupportedSyndicate = req.query.syndicate as string;
await inventory.save();
await Inventory.updateOne(
{
accountOwnerId: accountId
},
{
SupportedSyndicate: req.query.syndicate as string
}
);
res.end();
};

View File

@ -132,10 +132,6 @@ export interface IRewardInfo {
export type IMissionStatus = "GS_SUCCESS" | "GS_FAILURE" | "GS_DUMPED" | "GS_QUIT" | "GS_INTERRUPTED";
export interface IUpdateGlyphRequest {
AvatarImageType: string;
AvatarImage: string;
}
export interface IUpgradesRequest {
ItemCategory: TEquipmentKey;
ItemId: IOid;