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 {