diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index 7dae8540..8aa2bc42 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -781,9 +781,25 @@ const loreFragmentScansSchema = new Schema( { _id: false } ); -const lotusCustomizationSchema = new Schema().add(ItemConfigSchema).add({ - Persona: String -}); +// const lotusCustomizationSchema = new Schema().add(ItemConfigSchema).add({ +// Persona: String +// }); + +// Laxer schema for cleanupInventory +const lotusCustomizationSchema = new Schema( + { + Skins: [String], + pricol: colorSchema, + attcol: Schema.Types.Mixed, + sigcol: Schema.Types.Mixed, + eyecol: Schema.Types.Mixed, + facial: Schema.Types.Mixed, + cloth: Schema.Types.Mixed, + syancol: Schema.Types.Mixed, + Persona: String + }, + { _id: false } +); const evolutionProgressSchema = new Schema( { diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 90ed22f5..c3d47ec6 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1847,6 +1847,25 @@ export const cleanupInventory = (inventory: TInventoryDatabaseDocument): void => logger.debug(`removing FreeFavorsEarned from LibrarySyndicate`); LibrarySyndicate.FreeFavorsEarned = undefined; } + + if (inventory.LotusCustomization) { + if ( + Array.isArray(inventory.LotusCustomization.attcol) || + Array.isArray(inventory.LotusCustomization.sigcol) || + Array.isArray(inventory.LotusCustomization.eyecol) || + Array.isArray(inventory.LotusCustomization.facial) || + Array.isArray(inventory.LotusCustomization.cloth) || + Array.isArray(inventory.LotusCustomization.syancol) + ) { + logger.debug(`fixing empty objects represented as empty arrays in LotusCustomization`); + inventory.LotusCustomization.attcol = {}; + inventory.LotusCustomization.sigcol = {}; + inventory.LotusCustomization.eyecol = {}; + inventory.LotusCustomization.facial = {}; + inventory.LotusCustomization.cloth = {}; + inventory.LotusCustomization.syancol = {}; + } + } }; export const getCalendarProgress = (inventory: TInventoryDatabaseDocument): ICalendarProgress => {