forked from OpenWF/SpaceNinjaServer
		
	fix: handle DuviriInfo being absent from inventory (#1926)
Closes #1917 Reviewed-on: OpenWF/SpaceNinjaServer#1926 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
							
								
									3de68e51d5
								
							
						
					
					
						commit
						660768b53b
					
				@ -106,9 +106,16 @@ export const inventoryController: RequestHandler = async (request, response) =>
 | 
				
			|||||||
        const currentDuviriMood = Math.trunc(Date.now() / 7200000);
 | 
					        const currentDuviriMood = Math.trunc(Date.now() / 7200000);
 | 
				
			||||||
        if (lastSyncDuviriMood != currentDuviriMood) {
 | 
					        if (lastSyncDuviriMood != currentDuviriMood) {
 | 
				
			||||||
            logger.debug(`refreshing duviri seed`);
 | 
					            logger.debug(`refreshing duviri seed`);
 | 
				
			||||||
 | 
					            if (!inventory.DuviriInfo) {
 | 
				
			||||||
 | 
					                inventory.DuviriInfo = {
 | 
				
			||||||
 | 
					                    Seed: generateRewardSeed(),
 | 
				
			||||||
 | 
					                    NumCompletions: 0
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
                inventory.DuviriInfo.Seed = generateRewardSeed();
 | 
					                inventory.DuviriInfo.Seed = generateRewardSeed();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    inventory.LastInventorySync = new Types.ObjectId();
 | 
					    inventory.LastInventorySync = new Types.ObjectId();
 | 
				
			||||||
    await inventory.save();
 | 
					    await inventory.save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -391,8 +391,8 @@ MailboxSchema.set("toJSON", {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const DuviriInfoSchema = new Schema<IDuviriInfo>(
 | 
					const DuviriInfoSchema = new Schema<IDuviriInfo>(
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Seed: BigInt,
 | 
					        Seed: { type: BigInt, required: true },
 | 
				
			||||||
        NumCompletions: { type: Number, default: 0 }
 | 
					        NumCompletions: { type: Number, required: true }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        _id: false,
 | 
					        _id: false,
 | 
				
			||||||
 | 
				
			|||||||
@ -601,7 +601,7 @@ export const addMissionInventoryUpdates = async (
 | 
				
			|||||||
            case "duviriCaveOffers": {
 | 
					            case "duviriCaveOffers": {
 | 
				
			||||||
                // Duviri cave offers (generated with the duviri seed) change after completing one of its game modes (not when aborting).
 | 
					                // Duviri cave offers (generated with the duviri seed) change after completing one of its game modes (not when aborting).
 | 
				
			||||||
                if (inventoryUpdates.MissionStatus != "GS_QUIT") {
 | 
					                if (inventoryUpdates.MissionStatus != "GS_QUIT") {
 | 
				
			||||||
                    inventory.DuviriInfo.Seed = generateRewardSeed();
 | 
					                    inventory.DuviriInfo!.Seed = generateRewardSeed();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
@ -202,7 +202,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
 | 
				
			|||||||
    OperatorLoadOuts: IOperatorConfigClient[];
 | 
					    OperatorLoadOuts: IOperatorConfigClient[];
 | 
				
			||||||
    KahlLoadOuts: IOperatorConfigClient[];
 | 
					    KahlLoadOuts: IOperatorConfigClient[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DuviriInfo: IDuviriInfo;
 | 
					    DuviriInfo?: IDuviriInfo;
 | 
				
			||||||
    Mailbox?: IMailboxClient;
 | 
					    Mailbox?: IMailboxClient;
 | 
				
			||||||
    SubscribedToEmails: number;
 | 
					    SubscribedToEmails: number;
 | 
				
			||||||
    Created: IMongoDate;
 | 
					    Created: IMongoDate;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user