Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correction for /notification/decision endpoint #314

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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