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

Changes for sending mail before the job is scheduled, as part of sanity check for users #33

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports.sendEmail = function (email, subjectLine, slotDetails, callback) {
from: String('Vaccine Checker ' + process.env.EMAIL),
to: email,
subject: subjectLine,
text: 'Vaccine available. Details: \n\n' + slotDetails
text: slotDetails
};
nodemailerTransporter.sendMail(options, (error, info) => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this takes care of a misconfiguration (or anything) - and throws up if the mail could not be sent.

if (error) {
Expand Down
8 changes: 7 additions & 1 deletion vaccineNotifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const AGE = process.env.AGE

async function main(){
try {
notifier.sendEmail(EMAIL, 'Beginning to search for open slots', 'Start notification', (err, result) => {
if(err) {
console.error({err});
}
});

cron.schedule('* * * * *', async () => {
await checkAvailability();
});
Expand Down Expand Up @@ -64,7 +70,7 @@ function getSlotsForDate(DATE) {
async function

notifyMe(validSlots){
let slotDetails = JSON.stringify(validSlots, null, '\t');
let slotDetails = 'Vaccine available. Details: \n\n' + JSON.stringify(validSlots, null, '\t');
notifier.sendEmail(EMAIL, 'VACCINE AVAILABLE', slotDetails, (err, result) => {
if(err) {
console.error({err});
Expand Down