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