Skip to content

Commit

Permalink
correction for /notification/decision endpoint (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
hichri-louay committed Aug 21, 2023
2 parents 6c52bff + efc2133 commit eff9287
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions controllers/profile.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ exports.account = async (req, res) => {
exports.notificationDecision = async (req, res) => {
try {
if (!req.user) {
return makeResponseData(res, 200, 'success', 'user not found');
return makeResponseData(res, 200, 'user-not-found', false);
}
const user = req.user.toObject();
const requiredFields = [
Expand All @@ -169,8 +169,8 @@ exports.notificationDecision = async (req, res) => {
return acc;
}, 0);
const percentProf = (count * 100) / requiredFields.length;
if (percentProf === 100) {
return makeResponseData(res, 200, 'success', 'showing-complete-profile');
if (percentProf < 100) {
return makeResponseData(res, 200, 'showing-complete-profile', percentProf);
} else {
const wallet = await Wallet.findOne({UserId: req.user._id});
if(!!wallet) {
Expand All @@ -194,7 +194,7 @@ exports.notificationDecision = async (req, res) => {
}
}
if(Number(sattBalance) === 0) {
return makeResponseData(res, 200, 'success', 'showing-buy-satt');
return makeResponseData(res, 200, 'showing-buy-satt', true);
} else {
let gasBalance = 0;
for (const networkObj of networks) {
Expand All @@ -208,20 +208,20 @@ exports.notificationDecision = async (req, res) => {
}
}
if(Number(gasBalance) === 0) {
return makeResponseData(res, 200, 'success', 'showing-buy-fees');
return makeResponseData(res, 200, 'showing-buy-fees', true);
} else {
// CHECK NEW AD POOLS
const campaignActive = await Campaigns.findOne({type: 'apply'}).sort({ _id: -1 });
if(!!campaignActive) return makeResponseData(res, 200, 'success', campaignActive);
if(!!campaignActive) return makeResponseData(res, 200, 'showing-campaign', campaignActive.coverMobile);
else {
const randomNum = Math.floor(Math.random() * 3) + 1;
return makeResponseData(res, 200, 'success', randomNum);
return makeResponseData(res, 200, 'showing-random-number', randomNum);
}
}
}

} else {
return makeResponseData(res, 200, 'success', 'wallet not found');
return makeResponseData(res, 200, 'wallet-not-found', false);
}
}
} catch (err) {
Expand All @@ -234,7 +234,6 @@ exports.notificationDecision = async (req, res) => {
};



exports.profilePicture = async (req, response) => {
try {
const idUser = req.query.id ? +req.query.id : req.user._id;
Expand Down

0 comments on commit eff9287

Please sign in to comment.