-
-
Save JacobKnaack/2ca07e30952acd0200594f795c5efa85 to your computer and use it in GitHub Desktop.
Cosmic Messenger Twiliio Notifications middleware
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
var twilioClient = require('./twilioClient'); | |
const admins = require('./config').adminNumbers; | |
function formatMessage(user, messageText) { | |
return `Message from ${user}: ${messageText}`; | |
}; | |
exports.notifyOnMessage = function (req, res, next) { | |
if (req.session) { | |
const { title, content } = req.body; | |
admins.forEach(function (admin) { | |
var messageToSend = formatMessage(title, content); | |
twilioClient.sendSms(admin.phoneNumber, messageToSend); | |
}); | |
} | |
next(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment