返回提交历史
Modified
src/models/inventoryModels/inventoryModel.ts
+19
-3
Modified
src/services/importService.ts
+16
-1
Modified
src/services/inventoryService.ts
+19
-0
XFEstudio/SpaceNinjaServer
fix: import failing for LotusCustomization from live (#1891)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1891 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
45748fa8
代码差异
3 个文件
+54
-4
@@ -781,9 +781,25 @@ const loreFragmentScansSchema = new Schema<ILoreFragmentScan>(
781
781
{ _id: false }
782
782
);
783
783
784
const lotusCustomizationSchema = new Schema<ILotusCustomization>().add(ItemConfigSchema).add({
785
Persona: String
786
});
784
// const lotusCustomizationSchema = new Schema<ILotusCustomization>().add(ItemConfigSchema).add({
785
// Persona: String
786
// });
787
788
// Laxer schema for cleanupInventory
789
const lotusCustomizationSchema = new Schema<ILotusCustomization>(
790
{
791
Skins: [String],
792
pricol: colorSchema,
793
attcol: Schema.Types.Mixed,
794
sigcol: Schema.Types.Mixed,
795
eyecol: Schema.Types.Mixed,
796
facial: Schema.Types.Mixed,
797
cloth: Schema.Types.Mixed,
798
syancol: Schema.Types.Mixed,
799
Persona: String
800
},
801
{ _id: false }
802
);
787
803
788
804
const evolutionProgressSchema = new Schema<IEvolutionProgress>(
789
805
{
@@ -2,6 +2,7 @@ import { Types } from "mongoose";
2
2
import {
3
3
IEquipmentClient,
4
4
IEquipmentDatabase,
5
IItemConfig,
5
6
IOperatorConfigClient,
6
7
IOperatorConfigDatabase
7
8
} from "../types/inventoryTypes/commonInventoryTypes";
@@ -174,6 +175,20 @@ const convertNemesis = (client: INemesisClient): INemesisDatabase => {
174
175
};
175
176
};
176
177
178
// Empty objects from live may have been encoded as empty arrays because of PHP.
179
const convertItemConfig = <T extends IItemConfig>(client: T): T => {
180
return {
181
...client,
182
pricol: Array.isArray(client.pricol) ? {} : client.pricol,
183
attcol: Array.isArray(client.attcol) ? {} : client.attcol,
184
sigcol: Array.isArray(client.sigcol) ? {} : client.sigcol,
185
eyecol: Array.isArray(client.eyecol) ? {} : client.eyecol,
186
facial: Array.isArray(client.facial) ? {} : client.facial,
187
cloth: Array.isArray(client.cloth) ? {} : client.cloth,
188
syancol: Array.isArray(client.syancol) ? {} : client.syancol
189
};
190
};
191
177
192
export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
178
193
for (const key of equipmentKeys) {
179
194
if (client[key] !== undefined) {
@@ -352,7 +367,7 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
352
367
db.PlayerSkills = client.PlayerSkills;
353
368
}
354
369
if (client.LotusCustomization !== undefined) {
355
db.LotusCustomization = client.LotusCustomization;
370
db.LotusCustomization = convertItemConfig(client.LotusCustomization);
356
371
}
357
372
if (client.CollectibleSeries !== undefined) {
358
373
db.CollectibleSeries = client.CollectibleSeries;
@@ -1847,6 +1847,25 @@ export const cleanupInventory = (inventory: TInventoryDatabaseDocument): void =>
1847
1847
logger.debug(`removing FreeFavorsEarned from LibrarySyndicate`);
1848
1848
LibrarySyndicate.FreeFavorsEarned = undefined;
1849
1849
}
1850
1851
if (inventory.LotusCustomization) {
1852
if (
1853
Array.isArray(inventory.LotusCustomization.attcol) ||
1854
Array.isArray(inventory.LotusCustomization.sigcol) ||
1855
Array.isArray(inventory.LotusCustomization.eyecol) ||
1856
Array.isArray(inventory.LotusCustomization.facial) ||
1857
Array.isArray(inventory.LotusCustomization.cloth) ||
1858
Array.isArray(inventory.LotusCustomization.syancol)
1859
) {
1860
logger.debug(`fixing empty objects represented as empty arrays in LotusCustomization`);
1861
inventory.LotusCustomization.attcol = {};
1862
inventory.LotusCustomization.sigcol = {};
1863
inventory.LotusCustomization.eyecol = {};
1864
inventory.LotusCustomization.facial = {};
1865
inventory.LotusCustomization.cloth = {};
1866
inventory.LotusCustomization.syancol = {};
1867
}
1868
}
1850
1869
};
1851
1870
1852
1871
export const getCalendarProgress = (inventory: TInventoryDatabaseDocument): ICalendarProgress => {