Skip to content

Commit

Permalink
number Participation limit (#343)
Browse files Browse the repository at this point in the history
Update in the number of participation limit function in the backend
  • Loading branch information
HamdiBenK authored Sep 22, 2023
2 parents ca887a2 + 9231ce9 commit e5d1fe4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions controllers/campaign.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,16 @@ exports.apply = async (req, res) => {
} = req.body
let [prom, date, hash] = [{}, Math.floor(Date.now() / 1000), req.body.hash]
var campaignDetails = await Campaigns.findOne({ hash }).lean()
let limit = campaignDetails.limit;
let userWallet = await Wallet.findOne({ UserId: req.user._id })
let numberParticipation = await CampaignLink.find({ id_campaign: hash,id_wallet:"0x"+userWallet.walletV2.keystore.address}).count()
if (limit=== numberParticipation){
return responseHandler.makeResponseError(
res,
401,
'Limit participation reached'
)
}

try {
let promExist = await CampaignLink.exists({
Expand Down Expand Up @@ -924,7 +934,7 @@ exports.apply = async (req, res) => {
)
cred = await unlockV2(req, res)

let userWallet = await Wallet.findOne({ UserId: req.user._id })

let decryptAccount =
await cred.Web3BEP20.eth.accounts.wallet.decrypt(
[userWallet.walletV2.keystore],
Expand Down Expand Up @@ -2952,4 +2962,4 @@ module.exports.totalInvested = async (req, res) => {
err.message ? err.message : err.error
)
}
}
}

0 comments on commit e5d1fe4

Please sign in to comment.