diff --git a/src/controllers/api/rerollRandomModController.ts b/src/controllers/api/rerollRandomModController.ts index aa398d30..42fdf337 100644 --- a/src/controllers/api/rerollRandomModController.ts +++ b/src/controllers/api/rerollRandomModController.ts @@ -7,9 +7,9 @@ import { getRandomElement } from "@/src/services/rngService"; export const rerollRandomModController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); - const inventory = await getInventory(accountId); const request = getJSONfromString(String(req.body)) as RerollRandomModRequest; if ("ItemIds" in request) { + const inventory = await getInventory(accountId, "Upgrades MiscItems"); const upgrade = inventory.Upgrades.id(request.ItemIds[0])!; const fingerprint = JSON.parse(upgrade.UpgradeFingerprint!) as IUnveiledRivenFingerprint; @@ -41,6 +41,7 @@ export const rerollRandomModController: RequestHandler = async (req, res) => { cost: kuvaCost }); } else { + const inventory = await getInventory(accountId, "Upgrades"); const upgrade = inventory.Upgrades.id(request.ItemId)!; if (request.CommitReroll && upgrade.PendingRerollFingerprint) { upgrade.UpgradeFingerprint = upgrade.PendingRerollFingerprint; diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index e7567772..c58a17df 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -96,8 +96,11 @@ export const combineInventoryChanges = (InventoryChanges: IInventoryChanges, del } }; -export const getInventory = async (accountOwnerId: string): Promise => { - const inventory = await Inventory.findOne({ accountOwnerId: accountOwnerId }); +export const getInventory = async ( + accountOwnerId: string, + projection: string | undefined = undefined +): Promise => { + const inventory = await Inventory.findOne({ accountOwnerId: accountOwnerId }, projection); if (!inventory) { throw new Error(`Didn't find an inventory for ${accountOwnerId}`);