@@ -243,6 +243,26 @@ async function sendStatusUpdateEmail(req, res, next) {
243243 Services . Email . sendStatusUpdate ( account . firstName , account . email , req . body . status , next ) ;
244244 }
245245}
246+
247+ /**
248+ * Sends an email telling the user that they have applied. This is used exclusively when we POST a hacker.
249+ * @param {{body: {hacker: {accountId: string}}} } req
250+ * @param {* } res
251+ * @param {(err?:*)=>void } next
252+ */
253+ async function sendAppliedStatusEmail ( req , res , next ) {
254+ const hacker = req . body . hacker ;
255+ const account = await Services . Account . findById ( hacker . accountId ) ;
256+ if ( ! account ) {
257+ return next ( {
258+ status : 500 ,
259+ message : Constants . Error . GENERIC_500_MESSAGE ,
260+ error : { }
261+ } ) ;
262+ }
263+ Services . Email . sendStatusUpdate ( account . firstName , account . email , Constants . General . HACKER_STATUS_APPLIED , next ) ;
264+ }
265+
246266/**
247267 * If the current hacker's status is Constants.HACKER_STATUS_NONE, and the hacker's application is completed,
248268 * then it will change the status of the hacker to Constants.General.HACKER_STATUS_APPLIED, and then email the hacker to
@@ -450,6 +470,7 @@ module.exports = {
450470 uploadResume : Middleware . Util . asyncMiddleware ( uploadResume ) ,
451471 downloadResume : Middleware . Util . asyncMiddleware ( downloadResume ) ,
452472 sendStatusUpdateEmail : Middleware . Util . asyncMiddleware ( sendStatusUpdateEmail ) ,
473+ sendAppliedStatusEmail : Middleware . Util . asyncMiddleware ( sendAppliedStatusEmail ) ,
453474 updateHacker : Middleware . Util . asyncMiddleware ( updateHacker ) ,
454475 validateConfirmedStatus : Middleware . Util . asyncMiddleware ( validateConfirmedStatus ) ,
455476 checkDuplicateAccountLinks : Middleware . Util . asyncMiddleware ( checkDuplicateAccountLinks ) ,
0 commit comments