make sure all webui options trigger respective inventory syncs

This commit is contained in:
Sainan 2025-09-08 05:39:40 +02:00
parent 7b99502cf8
commit ed48e251f0
28 changed files with 60 additions and 14 deletions

View File

@ -3,6 +3,7 @@ import { getAccountIdForRequest } from "../../services/loginService.ts";
import type { RequestHandler } from "express";
import type { IInventoryClient, IUpgradeClient } from "../../types/inventoryTypes/inventoryTypes.ts";
import { addMods, getInventory } from "../../services/inventoryService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const artifactsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -57,6 +58,7 @@ export const artifactsController: RequestHandler = async (req, res) => {
}
res.send(itemId);
broadcastInventoryUpdate(req);
};
interface IArtifactsRequest {

View File

@ -1,6 +1,6 @@
import type { RequestHandler } from "express";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
import { addMiscItems, getInventory } from "../../services/inventoryService.ts";
import type { TEquipmentKey } from "../../types/inventoryTypes/inventoryTypes.ts";
@ -75,5 +75,5 @@ export const gildWeaponController: RequestHandler = async (req, res) => {
InventoryChanges: inventoryChanges,
AffiliationMods: affiliationMods
});
sendWsBroadcastTo(accountId, { update_inventory: true });
broadcastInventoryUpdate(req);
};

View File

@ -20,6 +20,7 @@ import {
applyCheatsToInfestedFoundry,
handleSubsumeCompletion
} from "../../services/infestedFoundryService.ts";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
export const infestedFoundryController: RequestHandler = async (req, res) => {
const account = await getAccountForRequest(req);
@ -363,6 +364,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
);
addRecipes(inventory, recipeChanges);
await inventory.save();
sendWsBroadcastTo(account._id.toString(), { sync_inventory: true });
}
res.end();
break;

View File

@ -2,6 +2,7 @@ import { getJSONfromString } from "../../helpers/stringHelpers.ts";
import { getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import type { RequestHandler } from "express";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const maturePetController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -19,6 +20,7 @@ export const maturePetController: RequestHandler = async (req, res) => {
: [details.DominantTraits.FurPattern, details.DominantTraits.FurPattern, details.DominantTraits.FurPattern],
unmature: data.revert
});
broadcastInventoryUpdate(req);
};
interface IMaturePetRequest {

View File

@ -1,6 +1,6 @@
import type { RequestHandler } from "express";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
import {
getInventory,
@ -197,5 +197,5 @@ export const modularWeaponCraftingController: RequestHandler = async (req, res)
MiscItems: miscItemChanges
}
});
sendWsBroadcastTo(accountId, { update_inventory: true });
broadcastInventoryUpdate(req);
};

View File

@ -3,7 +3,7 @@ import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getInventory, updateCurrency } from "../../services/inventoryService.ts";
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
import type { TEquipmentKey } from "../../types/inventoryTypes/inventoryTypes.ts";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
interface INameWeaponRequest {
ItemName: string;
@ -28,5 +28,5 @@ export const nameWeaponController: RequestHandler = async (req, res) => {
res.json({
InventoryChanges: currencyChanges
});
sendWsBroadcastTo(accountId, { update_inventory: true });
broadcastInventoryUpdate(req);
};

View File

@ -1,7 +1,7 @@
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
import { getInventory, updateCurrency } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
import type { RequestHandler } from "express";
export const releasePetController: RequestHandler = async (req, res) => {
@ -20,7 +20,7 @@ export const releasePetController: RequestHandler = async (req, res) => {
await inventory.save();
res.json({ inventoryChanges }); // Not a mistake; it's "inventoryChanges" here.
sendWsBroadcastTo(accountId, { update_inventory: true });
broadcastInventoryUpdate(req);
};
interface IReleasePetRequest {

View File

@ -1,7 +1,7 @@
import { getJSONfromString } from "../../helpers/stringHelpers.ts";
import { getInventory, updateCurrency } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
import type { RequestHandler } from "express";
@ -23,7 +23,7 @@ export const renamePetController: RequestHandler = async (req, res) => {
...data,
inventoryChanges: inventoryChanges
});
sendWsBroadcastTo(accountId, { update_inventory: true });
broadcastInventoryUpdate(req);
};
interface IRenamePetRequest {

View File

@ -1,6 +1,7 @@
import type { RequestHandler } from "express";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { Inventory } from "../../models/inventoryModels/inventoryModel.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const setSupportedSyndicateController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -15,4 +16,5 @@ export const setSupportedSyndicateController: RequestHandler = async (req, res)
);
res.end();
broadcastInventoryUpdate(req);
};

View File

@ -1,5 +1,6 @@
import { getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
import type { TEquipmentKey } from "../../types/inventoryTypes/inventoryTypes.ts";
import type { RequestHandler } from "express";
@ -19,6 +20,7 @@ export const abilityOverrideController: RequestHandler = async (req, res) => {
}
}
res.end();
broadcastInventoryUpdate(req);
};
interface IAbilityOverrideRequest {

View File

@ -3,6 +3,7 @@ import { getAccountIdForRequest } from "../../services/loginService.ts";
import { addFusionPoints, getInventory } from "../../services/inventoryService.ts";
import { getGuildForRequestEx, hasGuildPermission } from "../../services/guildService.ts";
import { GuildPermission } from "../../types/guildTypes.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const addCurrencyController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -24,6 +25,7 @@ export const addCurrencyController: RequestHandler = async (req, res) => {
}
if (!request.currency.startsWith("Vault")) {
await inventory.save();
broadcastInventoryUpdate(req);
}
res.end();
};

View File

@ -1,7 +1,7 @@
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getInventory, addItem } from "../../services/inventoryService.ts";
import type { RequestHandler } from "express";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const addItemsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -10,9 +10,9 @@ export const addItemsController: RequestHandler = async (req, res) => {
for (const request of requests) {
await addItem(inventory, request.ItemType, request.ItemCount, true, undefined, request.Fingerprint, true);
}
sendWsBroadcastTo(accountId, { sync_inventory: true });
await inventory.save();
res.end();
broadcastInventoryUpdate(req);
};
interface IAddItemRequest {

View File

@ -2,6 +2,7 @@ import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getInventory, addRecipes } from "../../services/inventoryService.ts";
import type { RequestHandler } from "express";
import { ExportRecipes } from "warframe-public-export-plus";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const addMissingHelminthBlueprintsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -21,4 +22,5 @@ export const addMissingHelminthBlueprintsController: RequestHandler = async (req
await inventory.save();
res.end();
broadcastInventoryUpdate(req);
};

View File

@ -2,6 +2,7 @@ import { getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import type { RequestHandler } from "express";
import { ExportArcanes, ExportUpgrades } from "warframe-public-export-plus";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const addMissingMaxRankModsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -41,4 +42,5 @@ export const addMissingMaxRankModsController: RequestHandler = async (req, res)
await inventory.save();
res.end();
broadcastInventoryUpdate(req);
};

View File

@ -1,6 +1,6 @@
import { applyClientEquipmentUpdates, getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
import type { IOid } from "../../types/commonTypes.ts";
import type { IEquipmentClient } from "../../types/equipmentTypes.ts";
import type { TEquipmentKey } from "../../types/inventoryTypes/inventoryTypes.ts";
@ -24,9 +24,9 @@ export const addXpController: RequestHandler = async (req, res) => {
}
applyClientEquipmentUpdates(inventory, gear, category as TEquipmentKey);
}
sendWsBroadcastTo(accountId, { sync_inventory: true });
await inventory.save();
res.end();
broadcastInventoryUpdate(req);
};
type IAddXpRequest = {

View File

@ -1,5 +1,6 @@
import { getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
import type { TEquipmentKey } from "../../types/inventoryTypes/inventoryTypes.ts";
import type { RequestHandler } from "express";
@ -20,6 +21,7 @@ export const changeModularPartsController: RequestHandler = async (req, res) =>
await inventory.save();
}
res.end();
broadcastInventoryUpdate(req);
};
interface IUpdateFingerPrintRequest {

View File

@ -1,6 +1,7 @@
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getInventory } from "../../services/inventoryService.ts";
import type { RequestHandler } from "express";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
const DEFAULT_UPGRADE_EXPIRY_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
@ -31,4 +32,5 @@ export const editSuitInvigorationUpgradeController: RequestHandler = async (req,
}
await inventory.save();
res.end();
broadcastInventoryUpdate(req);
};

View File

@ -3,6 +3,7 @@ import { getInventory } from "../../services/inventoryService.ts";
import { getLoadout } from "../../services/loadoutService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getPersonalRooms } from "../../services/personalRoomsService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
import type { IInventoryClient } from "../../types/inventoryTypes/inventoryTypes.ts";
import type { IGetShipResponse } from "../../types/personalRoomsTypes.ts";
import type { RequestHandler } from "express";
@ -32,6 +33,7 @@ export const importController: RequestHandler = async (req, res) => {
}
res.end();
broadcastInventoryUpdate(req);
};
interface IImportRequest {

View File

@ -9,6 +9,7 @@ import {
import { logger } from "../../utils/logger.ts";
import type { RequestHandler } from "express";
import { ExportKeys } from "warframe-public-export-plus";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const manageQuestsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -157,4 +158,5 @@ export const manageQuestsController: RequestHandler = async (req, res) => {
await inventory.save();
res.status(200).end();
broadcastInventoryUpdate(req);
};

View File

@ -1,6 +1,7 @@
import type { RequestHandler } from "express";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getInventory } from "../../services/inventoryService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const popArchonCrystalUpgradeController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -12,6 +13,7 @@ export const popArchonCrystalUpgradeController: RequestHandler = async (req, res
);
await inventory.save();
res.end();
broadcastInventoryUpdate(req);
return;
}
res.status(400).end();

View File

@ -1,6 +1,7 @@
import type { RequestHandler } from "express";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getInventory } from "../../services/inventoryService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const pushArchonCrystalUpgradeController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -15,6 +16,7 @@ export const pushArchonCrystalUpgradeController: RequestHandler = async (req, re
}
await inventory.save();
res.end();
broadcastInventoryUpdate(req);
return;
}
}

View File

@ -2,6 +2,7 @@ import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getInventory } from "../../services/inventoryService.ts";
import type { RequestHandler } from "express";
import { ExportBoosters } from "warframe-public-export-plus";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
const I32_MAX = 0x7fffffff;
@ -42,4 +43,5 @@ export const setBoosterController: RequestHandler = async (req, res) => {
}
await inventory.save();
res.end();
broadcastInventoryUpdate(req);
};

View File

@ -1,6 +1,7 @@
import { getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import type { RequestHandler } from "express";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const setEvolutionProgressController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -25,6 +26,7 @@ export const setEvolutionProgressController: RequestHandler = async (req, res) =
await inventory.save();
res.end();
broadcastInventoryUpdate(req);
};
type ISetEvolutionProgressRequest = {

View File

@ -2,19 +2,25 @@ import type { RequestHandler } from "express";
import { ExportResources, ExportVirtuals } from "warframe-public-export-plus";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { addItem, getInventory } from "../../services/inventoryService.ts";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
export const unlockAllCapturaScenesController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
let needSync = false;
for (const uniqueName of Object.keys(ExportResources)) {
if (resourceInheritsFrom(uniqueName, "/Lotus/Types/Items/MiscItems/PhotoboothTile")) {
await addItem(inventory, uniqueName, 1);
needSync = true;
}
}
await inventory.save();
res.end();
if (needSync) {
sendWsBroadcastTo(accountId, { sync_inventory: true });
}
};
const resourceInheritsFrom = (resourceName: string, targetName: string): boolean => {

View File

@ -1,6 +1,7 @@
import { getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import type { RequestHandler } from "express";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
export const unlockAllIntrinsicsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -16,4 +17,5 @@ export const unlockAllIntrinsicsController: RequestHandler = async (req, res) =>
inventory.PlayerSkills.LPS_DRIFT_ENDURANCE = 10;
await inventory.save();
res.end();
sendWsBroadcastTo(accountId, { sync_inventory: true });
};

View File

@ -1,6 +1,7 @@
import { getInventory } from "../../services/inventoryService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import type { RequestHandler } from "express";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
const allEudicoHeistJobs = [
"/Lotus/Types/Gameplay/Venus/Jobs/Heists/HeistProfitTakerBountyOne",
@ -21,4 +22,5 @@ export const unlockAllProfitTakerStagesController: RequestHandler = async (req,
}
await inventory.save();
res.end();
sendWsBroadcastTo(accountId, { sync_inventory: true });
};

View File

@ -1,6 +1,7 @@
import type { RequestHandler } from "express";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getInventory } from "../../services/inventoryService.ts";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
export const unlockAllSimarisResearchEntriesController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -17,4 +18,5 @@ export const unlockAllSimarisResearchEntriesController: RequestHandler = async (
].map(type => ({ TargetType: type, Scans: 10, Completed: true }));
await inventory.save();
res.end();
sendWsBroadcastTo(accountId, { sync_inventory: true });
};

View File

@ -2,6 +2,7 @@ import { getInventory } from "../../services/inventoryService.ts";
import type { WeaponTypeInternal } from "../../services/itemDataService.ts";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import type { RequestHandler } from "express";
import { sendWsBroadcastTo } from "../../services/wsService.ts";
export const updateFingerprintController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -22,6 +23,7 @@ export const updateFingerprintController: RequestHandler = async (req, res) => {
await inventory.save();
}
res.end();
sendWsBroadcastTo(accountId, { sync_inventory: true });
};
interface IUpdateFingerPrintRequest {