fix: handle DuviriInfo being absent from inventory #1926

Open
Sainan wants to merge 1 commits from duviri-fix into main
4 changed files with 12 additions and 5 deletions

View File

@ -106,9 +106,16 @@ export const inventoryController: RequestHandler = async (request, response) =>
const currentDuviriMood = Math.trunc(Date.now() / 7200000);
if (lastSyncDuviriMood != currentDuviriMood) {
logger.debug(`refreshing duviri seed`);
if (!inventory.DuviriInfo) {
inventory.DuviriInfo = {
Seed: generateRewardSeed(),
NumCompletions: 0
};
} else {
inventory.DuviriInfo.Seed = generateRewardSeed();
}
}
}
inventory.LastInventorySync = new Types.ObjectId();
await inventory.save();

View File

@ -391,8 +391,8 @@ MailboxSchema.set("toJSON", {
const DuviriInfoSchema = new Schema<IDuviriInfo>(
{
Seed: BigInt,
NumCompletions: { type: Number, default: 0 }
Seed: { type: BigInt, required: true },
NumCompletions: { type: Number, required: true }
},
{
_id: false,

View File

@ -611,7 +611,7 @@ export const addMissionInventoryUpdates = async (
case "duviriCaveOffers": {
// Duviri cave offers (generated with the duviri seed) change after completing one of its game modes (not when aborting).
if (inventoryUpdates.MissionStatus != "GS_QUIT") {
inventory.DuviriInfo.Seed = generateRewardSeed();
inventory.DuviriInfo!.Seed = generateRewardSeed();
}
break;
}

View File

@ -202,7 +202,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
OperatorLoadOuts: IOperatorConfigClient[];
KahlLoadOuts: IOperatorConfigClient[];
DuviriInfo: IDuviriInfo;
DuviriInfo?: IDuviriInfo;
Mailbox?: IMailboxClient;
SubscribedToEmails: number;
Created: IMongoDate;