fix: handle saveDialogue request without Data or Gift (#1853)
Needed to just set booleans when starting dating. Closes #1852 Reviewed-on: #1853 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
							
								
									a90d3a5156
								
							
						
					
					
						commit
						95c0ad7892
					
				@ -4,7 +4,6 @@ import { addEmailItem, getInventory, updateCurrency } from "@/src/services/inven
 | 
				
			|||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
import { ICompletedDialogue, IDialogueDatabase } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
					import { ICompletedDialogue, IDialogueDatabase } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
					import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
				
			||||||
import { logger } from "@/src/utils/logger";
 | 
					 | 
				
			||||||
import { RequestHandler } from "express";
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const saveDialogueController: RequestHandler = async (req, res) => {
 | 
					export const saveDialogueController: RequestHandler = async (req, res) => {
 | 
				
			||||||
@ -27,7 +26,6 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
        const dialogue = getDialogue(inventory, request.DialogueName);
 | 
					        const dialogue = getDialogue(inventory, request.DialogueName);
 | 
				
			||||||
        dialogue.Rank = request.Rank;
 | 
					        dialogue.Rank = request.Rank;
 | 
				
			||||||
        dialogue.Chemistry = request.Chemistry;
 | 
					        dialogue.Chemistry = request.Chemistry;
 | 
				
			||||||
        if (request.Data) {
 | 
					 | 
				
			||||||
        dialogue.QueuedDialogues = request.QueuedDialogues;
 | 
					        dialogue.QueuedDialogues = request.QueuedDialogues;
 | 
				
			||||||
        for (const bool of request.Booleans) {
 | 
					        for (const bool of request.Booleans) {
 | 
				
			||||||
            dialogue.Booleans.push(bool);
 | 
					            dialogue.Booleans.push(bool);
 | 
				
			||||||
@ -45,8 +43,6 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
                dialogue.Booleans.splice(index, 1);
 | 
					                dialogue.Booleans.splice(index, 1);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
            dialogue.Completed.push(request.Data);
 | 
					 | 
				
			||||||
            dialogue.AvailableDate = new Date(tomorrowAt0Utc);
 | 
					 | 
				
			||||||
        for (const info of request.OtherDialogueInfos) {
 | 
					        for (const info of request.OtherDialogueInfos) {
 | 
				
			||||||
            const otherDialogue = getDialogue(inventory, info.Dialogue);
 | 
					            const otherDialogue = getDialogue(inventory, info.Dialogue);
 | 
				
			||||||
            if (info.Tag != "") {
 | 
					            if (info.Tag != "") {
 | 
				
			||||||
@ -54,6 +50,9 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            otherDialogue.Chemistry += info.Value; // unsure
 | 
					            otherDialogue.Chemistry += info.Value; // unsure
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (request.Data) {
 | 
				
			||||||
 | 
					            dialogue.Completed.push(request.Data);
 | 
				
			||||||
 | 
					            dialogue.AvailableDate = new Date(tomorrowAt0Utc);
 | 
				
			||||||
            await inventory.save();
 | 
					            await inventory.save();
 | 
				
			||||||
            res.json({
 | 
					            res.json({
 | 
				
			||||||
                InventoryChanges: inventoryChanges,
 | 
					                InventoryChanges: inventoryChanges,
 | 
				
			||||||
@ -73,8 +72,6 @@ export const saveDialogueController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
                InventoryChanges: inventoryChanges,
 | 
					                InventoryChanges: inventoryChanges,
 | 
				
			||||||
                AvailableGiftDate: { $date: { $numberLong: tomorrowAt0Utc.toString() } }
 | 
					                AvailableGiftDate: { $date: { $numberLong: tomorrowAt0Utc.toString() } }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            logger.error(`saveDialogue request not fully handled: ${String(req.body)}`);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user