Skip to content
This repository has been archived by the owner on Oct 9, 2019. It is now read-only.

Commit

Permalink
Email documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
domfarolino committed Feb 27, 2018
1 parent 17d45aa commit 7cf4ed4
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions lib/api/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ const userCryptoPassword = process.env.MONGO_SALT;

/**
* This is used to send email verification emails to all
* registrants appear in the database but have not verified
* their email address.
* registrants that:
*
* - Have registered but not verified their email address
*
* It is intended to be called from the dashboard or manually.
* We use this to give people who haven't confirmed their email
Expand All @@ -37,12 +38,11 @@ routes.get('/sendEmailVerification', apiKeyValidator, eventDeadlineValidator, (r
});
});


/**
* This is used to send attendance confirmation emails to
* all registrants that:
*
* - Have verified their email addresses
* - Have verified their email address
* - Do not appear on the waitlist
* - Have not previously received an attendance confirmation email
*
Expand All @@ -62,6 +62,37 @@ routes.get('/sendConfirmation', apiKeyValidator, eventDeadlineValidator, (reques
});
});

/**
* This is used to send attendance confirmation emails to
* an individual registrant:
*
* - Exec has decided to include regardless of any other condition
*
* It is intended to be called from the dashboard or manually.
* We use this to give priority to someone or to send an attendance
* confirmation email to someone who might not have received it.
* Use with caution :)
*
* usage: /sendConfirmationToIndividual?key=<apikeyhere>
*/
routes.get('/sendConfirmationToIndividual', apiKeyValidator, (request, response) => {
const userEmail = request.query.userEmail;

Registrant.find({email: userEmail}, (err, registrants) => {
if (err || !registrants.length) return response.status(400).send(`Either something went wrong, or ${userEmail} could not be found`);

Registrant.update({email: userEmail}, {waitList: false}, (err, numberAffected, rawResponse) => {
if (err) {
console.error(err);
return response.status(400).send('Sorry, something went wrong');
}

sendConfirmationEmails(request, registrants);
response.json({"affected users": registrants.length});
}); // Registrant.update()
}); // Registrant.find()
});

/**
* This is used to send attendance confirmation emails to
* all registrants that are sitting ducks. A sitting duck is
Expand Down Expand Up @@ -89,7 +120,7 @@ routes.get('/sendConfirmationToSittingDucks', apiKeyValidator, eventDeadlineVali
});

/**
* This is used to send attendance confirmation emails to
* This is used to send attendance confirmation emails to all
* registrants that:
*
* - Have verified their email address
Expand All @@ -116,37 +147,6 @@ routes.get('/sendConfirmationToWaitlisted', apiKeyValidator, eventDeadlineValida
}); // Registrant.find
});

/**
* This is used to send attendance confirmation emails to
* an individual registrant:
*
* - Exec has decided to include regardless of any other condition
*
* It is intended to be called from the dashboard or manually.
* We use this to give priority to someone or to send an attendance
* confirmation email to someone who might not have received it.
* Use with caution :)
*
* usage: /sendConfirmationToIndividual?key=<apikeyhere>
*/
routes.get('/sendConfirmationToIndividual', apiKeyValidator, (request, response) => {
const userEmail = request.query.userEmail;

Registrant.find({email: userEmail}, (err, registrants) => {
if (err || !registrants.length) return response.status(400).send(`Either something went wrong, or ${userEmail} could not be found`);

Registrant.update({email: userEmail}, {waitList: false}, (err, numberAffected, rawResponse) => {
if (err) {
console.error(err);
return response.status(400).send('Sorry, something went wrong');
}

sendConfirmationEmails(request, registrants);
response.json({"affected users": registrants.length});
}); // Registrant.update()
}); // Registrant.find()
});

/**
* This is used to send the infoEmail1 email to all registrants that:
*
Expand Down

0 comments on commit 7cf4ed4

Please sign in to comment.