fix: address some client warnings about malformed inventory.php response #840
| @ -16,6 +16,8 @@ import { | ||||
| } from "warframe-public-export-plus"; | ||||
| import { handleSubsumeCompletion } from "./infestedFoundryController"; | ||||
| import { allDailyAffiliationKeys } from "@/src/services/inventoryService"; | ||||
| import { toOid } from "@/src/helpers/inventoryHelpers"; | ||||
| import { Types } from "mongoose"; | ||||
| 
 | ||||
| export const inventoryController: RequestHandler = async (request, response) => { | ||||
|     const account = await getAccountForRequest(request); | ||||
| @ -247,6 +249,8 @@ export const inventoryController: RequestHandler = async (request, response) => | ||||
|     // This determines if the "void fissures" tab is shown in navigation.
 | ||||
|     inventoryResponse.HasOwnedVoidProjectionsPreviously = true; | ||||
| 
 | ||||
|     inventoryResponse.LastInventorySync = toOid(new Types.ObjectId()); | ||||
| 
 | ||||
|     response.json(inventoryResponse); | ||||
| }; | ||||
| 
 | ||||
|  | ||||
| @ -62,7 +62,8 @@ import { | ||||
|     IOperatorConfigDatabase, | ||||
|     IPolarity, | ||||
|     IEquipmentDatabase, | ||||
|     IArchonCrystalUpgrade | ||||
|     IArchonCrystalUpgrade, | ||||
|     IEquipmentClient | ||||
| } from "@/src/types/inventoryTypes/commonInventoryTypes"; | ||||
| import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers"; | ||||
| import { EquipmentSelectionSchema } from "./loadoutModel"; | ||||
| @ -120,10 +121,14 @@ const polaritySchema = new Schema<IPolarity>( | ||||
|     { _id: false } | ||||
| ); | ||||
| 
 | ||||
| const abilityOverrideSchema = new Schema<IAbilityOverride>({ | ||||
|     Ability: String, | ||||
|     Index: Number | ||||
| }); | ||||
| const abilityOverrideSchema = new Schema<IAbilityOverride>( | ||||
|     { | ||||
|         Ability: String, | ||||
|         Index: Number | ||||
|     }, | ||||
|     { _id: false } | ||||
| ); | ||||
| 
 | ||||
| export const colorSchema = new Schema<IColor>( | ||||
|     { | ||||
|         t0: Number, | ||||
| @ -256,6 +261,13 @@ EquipmentSchema.set("toJSON", { | ||||
|     transform(_document, returnedObject) { | ||||
|         delete returnedObject._id; | ||||
|         delete returnedObject.__v; | ||||
| 
 | ||||
|         const db = returnedObject as IEquipmentDatabase; | ||||
|         const client = returnedObject as IEquipmentClient; | ||||
| 
 | ||||
|         if (db.InfestationDate) { | ||||
|             client.InfestationDate = toMongoDate(db.InfestationDate); | ||||
|         } | ||||
|     } | ||||
| }); | ||||
| 
 | ||||
| @ -949,8 +961,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>( | ||||
|         XPInfo: [TypeXPItemSchema], | ||||
|         //Mastery Rank next availability
 | ||||
|         TrainingDate: { type: Date, default: new Date(0) }, | ||||
|         //Retries rank up(3 time)
 | ||||
|         TrainingRetriesLeft: Number, | ||||
| 
 | ||||
|         //you saw last played Region when you opened the star map
 | ||||
|         LastRegionPlayed: String, | ||||
| @ -1101,7 +1111,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>( | ||||
|         ChallengesFixVersion: Number, | ||||
|         PlayedParkourTutorial: Boolean, | ||||
|         SubscribedToEmailsPersonalized: Number, | ||||
|         LastInventorySync: Schema.Types.Mixed, // this should be Schema.Types.ObjectId, but older inventories may break with that.
 | ||||
|         ActiveLandscapeTraps: [Schema.Types.Mixed], | ||||
|         RepVotes: [Schema.Types.Mixed], | ||||
|         LeagueTickets: [Schema.Types.Mixed], | ||||
| @ -1131,7 +1140,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>( | ||||
| 
 | ||||
|         DialogueHistory: dialogueHistorySchema | ||||
|     }, | ||||
|     { timestamps: { createdAt: "Created" } } | ||||
|     { timestamps: { createdAt: "Created", updatedAt: false } } | ||||
| ); | ||||
| 
 | ||||
| inventorySchema.set("toJSON", { | ||||
|  | ||||
| @ -208,7 +208,6 @@ export interface IInventoryClient extends IDailyAffiliations { | ||||
|     QuestKeys: IQuestKeyResponse[]; | ||||
|     FlavourItems: IFlavourItem[]; | ||||
|     Scoops: IEquipmentDatabase[]; | ||||
|     TrainingRetriesLeft: number; | ||||
|     LoadOutPresets: ILoadOutPresets; | ||||
|     CurrentLoadOutIds: IOid[]; // we store it in the database using this representation as well :/
 | ||||
|     Missions: IMission[]; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user