generated from edenia/full-stack-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
639 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
const addJoinRequest = require('./add-join-request.route') | ||
const addReferralRoute = require('./add-referral.route') | ||
const sendConfirmationRoute = require('./send-confirmation.route') | ||
const rejectJoinRequestRoute = require('./reject-join-request.route') | ||
const healthzRoute = require('./healthz.route') | ||
|
||
module.exports = [ | ||
addJoinRequest, | ||
addReferralRoute, | ||
sendConfirmationRoute, | ||
rejectJoinRequestRoute, | ||
healthzRoute | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const Joi = require('joi') | ||
const Boom = require('@hapi/boom') | ||
|
||
const { joinRequestService, affiliateService } = require('../services') | ||
const { mailUtil } = require('../utils') | ||
const { mailTemplate } = require('../utils/templates') | ||
|
||
module.exports = { | ||
method: 'POST', | ||
path: '/reject-join-request', | ||
handler: async ({ payload: { input } }) => { | ||
try { | ||
for (const account of input.accounts) { | ||
const joinRequest = await joinRequestService.findByAccount(account) | ||
const hasKYC = await affiliateService.checkKyc(input.account) | ||
|
||
if (hasKYC || !joinRequest) continue | ||
|
||
try { | ||
mailUtil.send({ | ||
account: account, | ||
to: joinRequest.email, | ||
subject: | ||
'Further action is required to activate your Proton Affiliate account', | ||
template: mailTemplate.generateRejectionByKYC | ||
}) | ||
} catch (err) { | ||
console.log(err) | ||
} | ||
} | ||
|
||
const transaction = await joinRequestService.removeJoinRequest( | ||
input.accounts | ||
) | ||
|
||
return { success: transaction.affected_rows > 0 } | ||
} catch (error) { | ||
throw Boom.badRequest(error.message, { code: 'BAD_REQUEST' }) | ||
} | ||
}, | ||
options: { | ||
validate: { | ||
payload: Joi.object({ | ||
input: Joi.object({ | ||
accounts: Joi.array().items(Joi.string()).required() | ||
}).required() | ||
}).options({ stripUnknown: true }) | ||
} | ||
} | ||
} |
Oops, something went wrong.