From 9b9ce190937a890dceab02b7bc4c487126f4f97b Mon Sep 17 00:00:00 2001 From: asyncnomi Date: Thu, 15 Dec 2022 10:53:10 +0100 Subject: [PATCH] bla --- .gitignore | 1 + index.js | 62 ++++++++++++++++++++++++++++-------------------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 6d72418..4c36317 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ package-lock.json prankdata.txt +activitydata.txt ldap-conf.json diff --git a/index.js b/index.js index 48ad37c..d9a08d0 100644 --- a/index.js +++ b/index.js @@ -117,40 +117,42 @@ fastify.post('/addPrank', async (request, reply) => { && "amount" in content && "supplement" in content) { let amount = parseInt(content.amount) - if (isNaN(amount)) { - return { - success: false, - why: "Unable to parse the amount as integer" - } - } - if (!Supplements.contains(content.supplement)) { - return { - success: false, - why: "This supplement isn't available" - } - } - if (amount < MaxAmountCrepe) { - let prankUid = makeid(16); - PrankData[prankUid] = { - creator: content.uid, - type: content.type, - where: content.where, - amount: amount, - supplement: content.supplement, - note: content.note, - state: "Pending", - manageBy: null - } - saveData(prankPath, PrankData); - return { - sucess: true, - uid: prankUid, - prank: PrankData[prankUid] + if (!isNaN(amount)) { + if (!Supplements.contains(content.supplement)) { + if (amount < MaxAmountCrepe) { + let prankUid = makeid(16); + PrankData[prankUid] = { + creator: content.uid, + type: content.type, + where: content.where, + amount: amount, + supplement: content.supplement, + note: content.note, + state: "Pending", + manageBy: null + } + saveData(prankPath, PrankData); + return { + sucess: true, + uid: prankUid, + prank: PrankData[prankUid] + } + } else { + return { + success: false, + why: "Too much" + } + } + } else { + return { + success: false, + why: "This supplement isn't available" + } } } else { return { success: false, - why: "Too much" + why: "Unable to parse the amount as integer" } } } else {