WIP: chore: some initial handling of legacy oid format
This at least allows mission inventory update to succeed on U19.4, which uses $id. U19.13 uses $oid. Might want to narrow down the breakpoint a bit more.
This commit is contained in:
parent
0e255067a8
commit
7fa299a57e
@ -29,6 +29,7 @@ import { version_compare } from "@/src/services/worldStateService";
|
|||||||
import { getPersonalRooms } from "@/src/services/personalRoomsService";
|
import { getPersonalRooms } from "@/src/services/personalRoomsService";
|
||||||
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
|
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
|
||||||
import { Ship } from "@/src/models/shipModel";
|
import { Ship } from "@/src/models/shipModel";
|
||||||
|
import { toLegacyOid } from "@/src/helpers/inventoryHelpers";
|
||||||
|
|
||||||
export const inventoryController: RequestHandler = async (request, response) => {
|
export const inventoryController: RequestHandler = async (request, response) => {
|
||||||
const account = await getAccountForRequest(request);
|
const account = await getAccountForRequest(request);
|
||||||
@ -306,19 +307,29 @@ export const getInventoryResponse = async (
|
|||||||
// Set 2FA enabled so trading post can be used
|
// Set 2FA enabled so trading post can be used
|
||||||
inventoryResponse.HWIDProtectEnabled = true;
|
inventoryResponse.HWIDProtectEnabled = true;
|
||||||
|
|
||||||
// Fix nemesis for older versions
|
if (buildLabel) {
|
||||||
if (
|
// Fix nemesis for older versions
|
||||||
inventoryResponse.Nemesis &&
|
if (inventoryResponse.Nemesis && !isNemesisCompatibleWithVersion(inventoryResponse.Nemesis, buildLabel)) {
|
||||||
buildLabel &&
|
inventoryResponse.Nemesis = undefined;
|
||||||
!isNemesisCompatibleWithVersion(inventoryResponse.Nemesis, buildLabel)
|
}
|
||||||
) {
|
|
||||||
inventoryResponse.Nemesis = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buildLabel && version_compare(buildLabel, "2018.02.22.14.34") < 0) {
|
if (version_compare(buildLabel, "2018.02.22.14.34") < 0) {
|
||||||
const personalRoomsDb = await getPersonalRooms(inventory.accountOwnerId.toString());
|
const personalRoomsDb = await getPersonalRooms(inventory.accountOwnerId.toString());
|
||||||
const personalRooms = personalRoomsDb.toJSON<IPersonalRoomsClient>();
|
const personalRooms = personalRoomsDb.toJSON<IPersonalRoomsClient>();
|
||||||
inventoryResponse.Ship = personalRooms.Ship;
|
inventoryResponse.Ship = personalRooms.Ship;
|
||||||
|
|
||||||
|
if (version_compare(buildLabel, "2017.03.06.15.49") < 0) {
|
||||||
|
// U19.4 and below use $id instead of $oid
|
||||||
|
for (const category of equipmentKeys) {
|
||||||
|
for (const item of inventoryResponse[category]) {
|
||||||
|
toLegacyOid(item.ItemId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const upgrade of inventoryResponse.Upgrades) {
|
||||||
|
toLegacyOid(upgrade.ItemId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return inventoryResponse;
|
return inventoryResponse;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { IMongoDate, IOid } from "@/src/types/commonTypes";
|
import { IMongoDate, IOid, IOidWithLegacySupport } from "@/src/types/commonTypes";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { TRarity } from "warframe-public-export-plus";
|
import { TRarity } from "warframe-public-export-plus";
|
||||||
|
|
||||||
@ -6,6 +6,17 @@ export const toOid = (objectId: Types.ObjectId): IOid => {
|
|||||||
return { $oid: objectId.toString() } satisfies IOid;
|
return { $oid: objectId.toString() } satisfies IOid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const toLegacyOid = (oid: IOidWithLegacySupport): void => {
|
||||||
|
if (!("$id" in oid)) {
|
||||||
|
oid.$id = oid.$oid;
|
||||||
|
delete oid.$oid;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fromOid = (oid: IOidWithLegacySupport): string => {
|
||||||
|
return (oid.$oid ?? oid.$id)!;
|
||||||
|
};
|
||||||
|
|
||||||
export const toMongoDate = (date: Date): IMongoDate => {
|
export const toMongoDate = (date: Date): IMongoDate => {
|
||||||
return { $date: { $numberLong: date.getTime().toString() } };
|
return { $date: { $numberLong: date.getTime().toString() } };
|
||||||
};
|
};
|
||||||
|
@ -70,6 +70,7 @@ import { createShip } from "./shipService";
|
|||||||
import {
|
import {
|
||||||
catbrowDetails,
|
catbrowDetails,
|
||||||
fromMongoDate,
|
fromMongoDate,
|
||||||
|
fromOid,
|
||||||
kubrowDetails,
|
kubrowDetails,
|
||||||
kubrowFurPatternsWeights,
|
kubrowFurPatternsWeights,
|
||||||
kubrowWeights,
|
kubrowWeights,
|
||||||
@ -1491,9 +1492,9 @@ export const applyClientEquipmentUpdates = (
|
|||||||
const category = inventory[categoryName];
|
const category = inventory[categoryName];
|
||||||
|
|
||||||
gearArray.forEach(({ ItemId, XP, InfestationDate }) => {
|
gearArray.forEach(({ ItemId, XP, InfestationDate }) => {
|
||||||
const item = category.id(ItemId.$oid);
|
const item = category.id(fromOid(ItemId));
|
||||||
if (!item) {
|
if (!item) {
|
||||||
throw new Error(`No item with id ${ItemId.$oid} in ${categoryName}`);
|
throw new Error(`No item with id ${fromOid(ItemId)} in ${categoryName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XP) {
|
if (XP) {
|
||||||
|
@ -62,6 +62,7 @@ import { getLiteSortie, getSortie, idToBountyCycle, idToDay, idToWeek, pushClass
|
|||||||
import { config } from "./configService";
|
import { config } from "./configService";
|
||||||
import libraryDailyTasks from "@/static/fixed_responses/libraryDailyTasks.json";
|
import libraryDailyTasks from "@/static/fixed_responses/libraryDailyTasks.json";
|
||||||
import { ISyndicateMissionInfo } from "../types/worldStateTypes";
|
import { ISyndicateMissionInfo } from "../types/worldStateTypes";
|
||||||
|
import { fromOid } from "../helpers/inventoryHelpers";
|
||||||
|
|
||||||
const getRotations = (rewardInfo: IRewardInfo, tierOverride?: number): number[] => {
|
const getRotations = (rewardInfo: IRewardInfo, tierOverride?: number): number[] => {
|
||||||
// For Spy missions, e.g. 3 vaults cracked = A, B, C
|
// For Spy missions, e.g. 3 vaults cracked = A, B, C
|
||||||
@ -399,7 +400,7 @@ export const addMissionInventoryUpdates = async (
|
|||||||
break;
|
break;
|
||||||
case "Upgrades":
|
case "Upgrades":
|
||||||
value.forEach(clientUpgrade => {
|
value.forEach(clientUpgrade => {
|
||||||
const upgrade = inventory.Upgrades.id(clientUpgrade.ItemId.$oid)!;
|
const upgrade = inventory.Upgrades.id(fromOid(clientUpgrade.ItemId))!;
|
||||||
upgrade.UpgradeFingerprint = clientUpgrade.UpgradeFingerprint; // primitive way to copy over the riven challenge progress
|
upgrade.UpgradeFingerprint = clientUpgrade.UpgradeFingerprint; // primitive way to copy over the riven challenge progress
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -4,6 +4,11 @@ export interface IOid {
|
|||||||
$oid: string;
|
$oid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IOidWithLegacySupport {
|
||||||
|
$oid?: string;
|
||||||
|
$id?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IMongoDate {
|
export interface IMongoDate {
|
||||||
$date: {
|
$date: {
|
||||||
$numberLong: string;
|
$numberLong: string;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { IMongoDate, IOid } from "@/src/types/commonTypes";
|
import { IMongoDate, IOid, IOidWithLegacySupport } from "@/src/types/commonTypes";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import {
|
import {
|
||||||
ICrewShipCustomization,
|
ICrewShipCustomization,
|
||||||
@ -92,7 +92,7 @@ export interface IEquipmentClient
|
|||||||
IEquipmentDatabase,
|
IEquipmentDatabase,
|
||||||
"_id" | "InfestationDate" | "Expiry" | "UpgradesExpiry" | "UmbraDate" | "CrewMembers" | "Details"
|
"_id" | "InfestationDate" | "Expiry" | "UpgradesExpiry" | "UmbraDate" | "CrewMembers" | "Details"
|
||||||
> {
|
> {
|
||||||
ItemId: IOid;
|
ItemId: IOidWithLegacySupport;
|
||||||
InfestationDate?: IMongoDate;
|
InfestationDate?: IMongoDate;
|
||||||
Expiry?: IMongoDate;
|
Expiry?: IMongoDate;
|
||||||
UpgradesExpiry?: IMongoDate;
|
UpgradesExpiry?: IMongoDate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user