Compare commits

...

3 Commits

Author SHA1 Message Date
cfa7def9d1 fix null in inventory response
All checks were successful
Build / build (push) Successful in 47s
Build / build (pull_request) Successful in 1m7s
2025-06-17 00:03:57 +02:00
a1e56df519 this ain't needed 2025-06-17 00:00:05 +02:00
c1bf69b144 fix: ensure helminth shard operations don't produce a null shard
All checks were successful
Build / build (push) Successful in 53s
Build / build (pull_request) Successful in 1m6s
2025-06-16 17:37:32 +02:00
2 changed files with 10 additions and 9 deletions

View File

@ -30,8 +30,9 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
const request = getJSONfromString<IShardInstallRequest>(String(req.body)); const request = getJSONfromString<IShardInstallRequest>(String(req.body));
const inventory = await getInventory(account._id.toString()); const inventory = await getInventory(account._id.toString());
const suit = inventory.Suits.id(request.SuitId.$oid)!; const suit = inventory.Suits.id(request.SuitId.$oid)!;
if (!suit.ArchonCrystalUpgrades || suit.ArchonCrystalUpgrades.length != 5) { suit.ArchonCrystalUpgrades ??= [];
suit.ArchonCrystalUpgrades = [{}, {}, {}, {}, {}]; while (suit.ArchonCrystalUpgrades.length < request.Slot) {
suit.ArchonCrystalUpgrades.push({});
} }
suit.ArchonCrystalUpgrades[request.Slot] = { suit.ArchonCrystalUpgrades[request.Slot] = {
UpgradeType: request.UpgradeType, UpgradeType: request.UpgradeType,
@ -92,7 +93,8 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
} }
// remove from suit // remove from suit
suit.ArchonCrystalUpgrades![request.Slot] = {}; suit.ArchonCrystalUpgrades![request.Slot].UpgradeType = undefined;
suit.ArchonCrystalUpgrades![request.Slot].Color = undefined;
await inventory.save(); await inventory.save();

View File

@ -251,12 +251,6 @@ const ArchonCrystalUpgradeSchema = new Schema<IArchonCrystalUpgrade>(
{ _id: false } { _id: false }
); );
ArchonCrystalUpgradeSchema.set("toJSON", {
transform(_document, returnedObject) {
delete returnedObject.__v;
}
});
const boosterSchema = new Schema<IBooster>( const boosterSchema = new Schema<IBooster>(
{ {
ExpiryDate: Number, ExpiryDate: Number,
@ -1079,6 +1073,11 @@ EquipmentSchema.set("toJSON", {
if (db.UmbraDate) { if (db.UmbraDate) {
client.UmbraDate = toMongoDate(db.UmbraDate); client.UmbraDate = toMongoDate(db.UmbraDate);
} }
if (client.ArchonCrystalUpgrades) {
// For some reason, mongoose turns empty objects here into nulls, so we have to fix it.
client.ArchonCrystalUpgrades = client.ArchonCrystalUpgrades.map(x => (x as unknown) ?? {});
}
} }
}); });