forked from OpenWF/SpaceNinjaServer
Compare commits
No commits in common. "58ea73a116e56f95249904d8642bcede2243e387" and "ef8c81ee9e2f871fe17cd52d2e62e52d4ba29510" have entirely different histories.
58ea73a116
...
ef8c81ee9e
@ -23,21 +23,13 @@ export const setBoosterController: RequestHandler = async (req, res) => {
|
||||
res.status(400).send("Invalid ItemType provided.");
|
||||
return;
|
||||
}
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
// Remove if ExpiryDate lower than current time?
|
||||
for (const { ItemType, ExpiryDate } of requests) {
|
||||
if (ExpiryDate < now) {
|
||||
// remove expired boosters
|
||||
const index = boosters.findIndex(item => item.ItemType === ItemType);
|
||||
if (index !== -1) {
|
||||
boosters.splice(index, 1);
|
||||
}
|
||||
const boosterItem = boosters.find(item => item.ItemType === ItemType);
|
||||
if (boosterItem) {
|
||||
boosterItem.ExpiryDate = ExpiryDate;
|
||||
} else {
|
||||
const boosterItem = boosters.find(item => item.ItemType === ItemType);
|
||||
if (boosterItem) {
|
||||
boosterItem.ExpiryDate = ExpiryDate;
|
||||
} else {
|
||||
boosters.push({ ItemType, ExpiryDate });
|
||||
}
|
||||
boosters.push({ ItemType, ExpiryDate });
|
||||
}
|
||||
}
|
||||
await inventory.save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user