forked from OpenWF/SpaceNinjaServer
fix: import failing for LotusCustomization from live (#1891)
Reviewed-on: OpenWF/SpaceNinjaServer#1891 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
afec59e8a6
commit
45748fa8be
@ -781,9 +781,25 @@ const loreFragmentScansSchema = new Schema<ILoreFragmentScan>(
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const lotusCustomizationSchema = new Schema<ILotusCustomization>().add(ItemConfigSchema).add({
|
||||
Persona: String
|
||||
});
|
||||
// const lotusCustomizationSchema = new Schema<ILotusCustomization>().add(ItemConfigSchema).add({
|
||||
// Persona: String
|
||||
// });
|
||||
|
||||
// Laxer schema for cleanupInventory
|
||||
const lotusCustomizationSchema = new Schema<ILotusCustomization>(
|
||||
{
|
||||
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<IEvolutionProgress>(
|
||||
{
|
||||
|
@ -2,6 +2,7 @@ import { Types } from "mongoose";
|
||||
import {
|
||||
IEquipmentClient,
|
||||
IEquipmentDatabase,
|
||||
IItemConfig,
|
||||
IOperatorConfigClient,
|
||||
IOperatorConfigDatabase
|
||||
} from "../types/inventoryTypes/commonInventoryTypes";
|
||||
@ -174,6 +175,20 @@ const convertNemesis = (client: INemesisClient): INemesisDatabase => {
|
||||
};
|
||||
};
|
||||
|
||||
// Empty objects from live may have been encoded as empty arrays because of PHP.
|
||||
const convertItemConfig = <T extends IItemConfig>(client: T): T => {
|
||||
return {
|
||||
...client,
|
||||
pricol: Array.isArray(client.pricol) ? {} : client.pricol,
|
||||
attcol: Array.isArray(client.attcol) ? {} : client.attcol,
|
||||
sigcol: Array.isArray(client.sigcol) ? {} : client.sigcol,
|
||||
eyecol: Array.isArray(client.eyecol) ? {} : client.eyecol,
|
||||
facial: Array.isArray(client.facial) ? {} : client.facial,
|
||||
cloth: Array.isArray(client.cloth) ? {} : client.cloth,
|
||||
syancol: Array.isArray(client.syancol) ? {} : client.syancol
|
||||
};
|
||||
};
|
||||
|
||||
export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
|
||||
for (const key of equipmentKeys) {
|
||||
if (client[key] !== undefined) {
|
||||
@ -352,7 +367,7 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
|
||||
db.PlayerSkills = client.PlayerSkills;
|
||||
}
|
||||
if (client.LotusCustomization !== undefined) {
|
||||
db.LotusCustomization = client.LotusCustomization;
|
||||
db.LotusCustomization = convertItemConfig(client.LotusCustomization);
|
||||
}
|
||||
if (client.CollectibleSeries !== undefined) {
|
||||
db.CollectibleSeries = client.CollectibleSeries;
|
||||
|
@ -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 => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user