From 95c0ad78929f4c06dcc2e208c4e0601944a3d35e Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Sat, 26 Apr 2025 11:54:25 -0700 Subject: [PATCH] fix: handle saveDialogue request without Data or Gift (#1853) Needed to just set booleans when starting dating. Closes #1852 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1853 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/controllers/api/saveDialogueController.ts | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/src/controllers/api/saveDialogueController.ts b/src/controllers/api/saveDialogueController.ts index 49cc605c..a6a5f4f2 100644 --- a/src/controllers/api/saveDialogueController.ts +++ b/src/controllers/api/saveDialogueController.ts @@ -4,7 +4,6 @@ import { addEmailItem, getInventory, updateCurrency } from "@/src/services/inven import { getAccountIdForRequest } from "@/src/services/loginService"; import { ICompletedDialogue, IDialogueDatabase } from "@/src/types/inventoryTypes/inventoryTypes"; import { IInventoryChanges } from "@/src/types/purchaseTypes"; -import { logger } from "@/src/utils/logger"; import { RequestHandler } from "express"; export const saveDialogueController: RequestHandler = async (req, res) => { @@ -27,33 +26,33 @@ export const saveDialogueController: RequestHandler = async (req, res) => { const dialogue = getDialogue(inventory, request.DialogueName); dialogue.Rank = request.Rank; dialogue.Chemistry = request.Chemistry; + dialogue.QueuedDialogues = request.QueuedDialogues; + for (const bool of request.Booleans) { + dialogue.Booleans.push(bool); + if (bool == "LizzieShawzin") { + await addEmailItem( + inventory, + "/Lotus/Types/Items/EmailItems/LizzieShawzinSkinEmailItem", + inventoryChanges + ); + } + } + for (const bool of request.ResetBooleans) { + const index = dialogue.Booleans.findIndex(x => x == bool); + if (index != -1) { + dialogue.Booleans.splice(index, 1); + } + } + for (const info of request.OtherDialogueInfos) { + const otherDialogue = getDialogue(inventory, info.Dialogue); + if (info.Tag != "") { + otherDialogue.QueuedDialogues.push(info.Tag); + } + otherDialogue.Chemistry += info.Value; // unsure + } if (request.Data) { - dialogue.QueuedDialogues = request.QueuedDialogues; - for (const bool of request.Booleans) { - dialogue.Booleans.push(bool); - if (bool == "LizzieShawzin") { - await addEmailItem( - inventory, - "/Lotus/Types/Items/EmailItems/LizzieShawzinSkinEmailItem", - inventoryChanges - ); - } - } - for (const bool of request.ResetBooleans) { - const index = dialogue.Booleans.findIndex(x => x == bool); - if (index != -1) { - dialogue.Booleans.splice(index, 1); - } - } dialogue.Completed.push(request.Data); dialogue.AvailableDate = new Date(tomorrowAt0Utc); - for (const info of request.OtherDialogueInfos) { - const otherDialogue = getDialogue(inventory, info.Dialogue); - if (info.Tag != "") { - otherDialogue.QueuedDialogues.push(info.Tag); - } - otherDialogue.Chemistry += info.Value; // unsure - } await inventory.save(); res.json({ InventoryChanges: inventoryChanges, @@ -73,8 +72,6 @@ export const saveDialogueController: RequestHandler = async (req, res) => { InventoryChanges: inventoryChanges, AvailableGiftDate: { $date: { $numberLong: tomorrowAt0Utc.toString() } } }); - } else { - logger.error(`saveDialogue request not fully handled: ${String(req.body)}`); } } };