This commit is contained in:
asyncnomi 2022-12-15 10:53:10 +01:00
parent 401d793da4
commit 9b9ce19093
2 changed files with 33 additions and 30 deletions

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
node_modules/
package-lock.json
prankdata.txt
activitydata.txt
ldap-conf.json

View file

@ -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 {