diff --git a/src/controllers/api/inventoryController.ts b/src/controllers/api/inventoryController.ts index bede097f..ab739c4c 100644 --- a/src/controllers/api/inventoryController.ts +++ b/src/controllers/api/inventoryController.ts @@ -14,7 +14,12 @@ import { ExportVirtuals } from "warframe-public-export-plus"; import { applyCheatsToInfestedFoundry, handleSubsumeCompletion } from "@/src/services/infestedFoundryService"; -import { addMiscItems, allDailyAffiliationKeys, createLibraryDailyTask } from "@/src/services/inventoryService"; +import { + addMiscItems, + allDailyAffiliationKeys, + cleanupInventory, + createLibraryDailyTask +} from "@/src/services/inventoryService"; import { logger } from "@/src/utils/logger"; import { catBreadHash } from "@/src/helpers/stringHelpers"; @@ -79,6 +84,8 @@ export const inventoryController: RequestHandler = async (request, response) => } } + cleanupInventory(inventory); + inventory.NextRefill = new Date((Math.trunc(Date.now() / 86400000) + 1) * 86400000); await inventory.save(); } diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 7537c8d6..5ca5634f 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1671,3 +1671,23 @@ export const setupKahlSyndicate = (inventory: TInventoryDatabaseDocument): void Tag: "KahlSyndicate" }); }; + +export const cleanupInventory = (inventory: TInventoryDatabaseDocument): void => { + let index = inventory.MiscItems.findIndex(x => x.ItemType == ""); + if (index != -1) { + inventory.MiscItems.splice(index, 1); + } + + index = inventory.Affiliations.findIndex(x => x.Tag == "KahlSyndicate"); + if (index != -1 && !inventory.Affiliations[index].WeeklyMissions) { + logger.debug(`KahlSyndicate seems broken, removing it and setting up again`); + inventory.Affiliations.splice(index, 1); + setupKahlSyndicate(inventory); + } + + const LibrarySyndicate = inventory.Affiliations.find(x => x.Tag == "LibrarySyndicate"); + if (LibrarySyndicate && LibrarySyndicate.FreeFavorsEarned) { + logger.debug(`removing FreeFavorsEarned from LibrarySyndicate`); + LibrarySyndicate.FreeFavorsEarned = undefined; + } +};