Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

Commit

Permalink
Twilio
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hobden committed Mar 22, 2016
1 parent 7728f9e commit a320595
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/cronjobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ module.exports = function(db) {
msg = String(msg.slice(0, 153) + "..");
}

console.log("To: ", phone, "Msg("+ msg.length + "): ", msg);
// console.log(" To: ", phone, "Msg("+ msg.length + "): ", msg);

// client.sendMessage({
// to: phone,
// from: '(778) 402-1767',
// body: msg,
// }, function(err, data) {
// if (err) { console.log(err); }
// else { console.log("Done sending to ", phone); }
// });
client.sendMessage({
to: phone,
from: '(778) 402-1767',
body: msg,
}, function(err, data) {
if (err) { console.log(err); }
else { console.log("Done sending to ", phone); }
});
}

// Pass in like `new Date("Thu Sep 14 2015")`
Expand Down Expand Up @@ -54,14 +54,18 @@ module.exports = function(db) {
where: { approved: true, },
}],
}).then(function (sessions) {
console.log(sessions);
// console.log(sessions);
_.each(sessions, function (session) {
console.log("On session of ", session.Workshop.title);
var startTime = moment(session.start).format('h:mm a');
_.each(session.Members, function (member) {
console.log("Sending message to", member.name);
var msg = "Start: " + startTime + ", At: " + session.room + " " + session.venue + ", Wkshp: " + session.Workshop.title;
sendSMS(member.phone, msg);
if (member.phone) {
console.log(" Sending message to", member.name);
var msg = "Start: " + startTime + ", At: " + session.room + " " + session.venue + ", Wkshp: " + session.Workshop.title;
sendSMS(member.phone, msg);
} else {
console.log(" Skipping message to", member.name);
}
});
});
}).catch(function (err) {
Expand All @@ -87,7 +91,7 @@ module.exports = function(db) {

console.log("Hooking cronjobs...");
return [
setupCron("Mar 22 2016 07:30:00"),
setupCron("Mar 22 2016 07:11:00"),
setupCron("Mar 23 2016 07:30:00"),
];
};

0 comments on commit a320595

Please sign in to comment.