From ed54e00a03127929e6df11b7ebd08a304080b638 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 30 Apr 2025 13:28:24 -0700 Subject: [PATCH] fix: compatibility with echoes of duviri (#1928) Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1928 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/controllers/api/inboxController.ts | 15 ++++++++++++--- src/services/worldStateService.ts | 22 ++++++++++++++++++++++ src/types/worldStateTypes.ts | 13 +++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/controllers/api/inboxController.ts b/src/controllers/api/inboxController.ts index 7462de3e..94d253ad 100644 --- a/src/controllers/api/inboxController.ts +++ b/src/controllers/api/inboxController.ts @@ -14,6 +14,7 @@ import { logger } from "@/src/utils/logger"; import { ExportFlavour } from "warframe-public-export-plus"; import { handleStoreItemAcquisition } from "@/src/services/purchaseService"; import { fromStoreItem, isStoreItem } from "@/src/services/itemDataService"; +import { IOid } from "@/src/types/commonTypes"; export const inboxController: RequestHandler = async (req, res) => { const { deleteId, lastMessage: latestClientMessageId, messageId } = req.query; @@ -28,10 +29,10 @@ export const inboxController: RequestHandler = async (req, res) => { return; } - await deleteMessageRead(deleteId as string); + await deleteMessageRead(parseOid(deleteId as string)); res.status(200).end(); } else if (messageId) { - const message = await getMessage(messageId as string); + const message = await getMessage(parseOid(messageId as string)); message.r = true; await message.save(); @@ -100,7 +101,7 @@ export const inboxController: RequestHandler = async (req, res) => { await createNewEventMessages(req); const messages = await Inbox.find({ ownerId: accountId }).sort({ date: 1 }); - const latestClientMessage = messages.find(m => m._id.toString() === latestClientMessageId); + const latestClientMessage = messages.find(m => m._id.toString() === parseOid(latestClientMessageId as string)); if (!latestClientMessage) { logger.debug(`this should only happen after DeleteAllRead `); @@ -123,3 +124,11 @@ export const inboxController: RequestHandler = async (req, res) => { res.json({ Inbox: inbox }); } }; + +// 33.6.0 has query arguments like lastMessage={"$oid":"68112baebf192e786d1502bb"} instead of lastMessage=68112baebf192e786d1502bb +const parseOid = (oid: string): string => { + if (oid[0] == "{") { + return (JSON.parse(oid) as IOid).$oid; + } + return oid; +}; diff --git a/src/services/worldStateService.ts b/src/services/worldStateService.ts index e2e2ea23..9350360e 100644 --- a/src/services/worldStateService.ts +++ b/src/services/worldStateService.ts @@ -724,6 +724,11 @@ export const getWorldState = (buildLabel?: string): IWorldState => { SyndicateMissions: [...staticWorldState.SyndicateMissions] }; + // Omit void fissures for versions prior to Whispers in the Walls to avoid errors with the unknown deimos nodes having void fissures. + if (buildLabel && version_compare(buildLabel, "2023.11.06.13.39") <= 0) { + worldState.ActiveMissions = []; + } + if (config.worldState?.starDays) { worldState.Goals.push({ _id: { $oid: "67a4dcce2a198564d62e1647" }, @@ -1227,3 +1232,20 @@ export const isArchwingMission = (node: IRegion): boolean => { } return false; }; + +export const version_compare = (a: string, b: string): number => { + const a_digits = a + .split("/")[0] + .split(".") + .map(x => parseInt(x)); + const b_digits = b + .split("/")[0] + .split(".") + .map(x => parseInt(x)); + for (let i = 0; i != a_digits.length; ++i) { + if (a_digits[i] != b_digits[i]) { + return a_digits[i] > b_digits[i] ? 1 : -1; + } + } + return 0; +}; diff --git a/src/types/worldStateTypes.ts b/src/types/worldStateTypes.ts index 303c3c33..1e8d4033 100644 --- a/src/types/worldStateTypes.ts +++ b/src/types/worldStateTypes.ts @@ -10,6 +10,7 @@ export interface IWorldState { LiteSorties: ILiteSortie[]; SyndicateMissions: ISyndicateMissionInfo[]; GlobalUpgrades: IGlobalUpgrade[]; + ActiveMissions: IFissure[]; NodeOverrides: INodeOverride[]; EndlessXpChoices: IEndlessXpChoice[]; SeasonInfo: { @@ -71,6 +72,18 @@ export interface IGlobalUpgrade { LocalizeDescTag: string; } +export interface IFissure { + _id: IOid; + Region: number; + Seed: number; + Activation: IMongoDate; + Expiry: IMongoDate; + Node: string; + MissionType: string; + Modifier: string; + Hard?: boolean; +} + export interface INodeOverride { _id: IOid; Activation?: IMongoDate;