Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.sendSlackAlert = function (config, message, links) {
if (!config.slackWebhookUrl) {
console.error('Please add a Slack webhook URL on the Settings page to enable Slack notifications');
return;
}
const slackNotifier = new Notifme.default({
channels: {
slack: {
providers: [{
type: 'webhook',
webhookUrl: config.slackWebhookUrl
}]
}
}
});
// add links to the slack alert
let slackMsgObj = { slack: { text: message } };
if (links && links.length) {
slackMsgObj.slack.attachments = [];
for (let link of links) {
slackMsgObj.slack.attachments.push({
const nunjucks = require('nunjucks')
const NotifmeSdk = require('notifme-sdk').default
const getRenderer = require('..') // notifme-template
// Renderer (Example with nunjucks)
nunjucks.configure({autoescape: false})
const render = getRenderer(nunjucks.renderString, 'example/templates')
// Notif.me sender
const notifmeSdk = new NotifmeSdk({
useNotificationCatcher: true
})
// Render a template and send it
const data = {
smsFrom: 'Notifme',
emailFrom: '"David, Notif.me team" ',
user: {
firstname: 'John',
email: 'john@example.com',
phone: '+15000000001',
pushToken: 'xxxxx',
webpush: {
endpoint: 'xxxxx',
keys: {
auth: 'xxxxx',
exports.sendTwilioAlert = function (config, message, links) {
if (!config.accountSid || !config.authToken || !config.toNumber || !config.fromNumber) {
console.error('Please fill out the required fields for Twilio notifications on the Settings page.');
return;
}
const twilioNotifier = new Notifme.default({
channels: {
sms: {
providers: [{
type: 'twilio',
accountSid: config.accountSid,
authToken: config.authToken
}]
}
}
});
if (links && links.length) {
for (let link of links) {
message += `\n${link.text}: ${link.url}`;
}
}
exports.sendEmailAlert = function (config, message, links) {
if (!config.host || !config.port || !config.to || !config.from) {
console.error('Please fill out the required fields for Email notifications on the Settings page.');
return;
}
if (!config.secure) {
config.secure = false;
}
const emailNotifier = new Notifme.default({
channels: {
email: {
providers: [{
type: 'smtp',
host: config.host,
port: config.port,
secure: config.secure,
auth: {
user: config.user,
pass: config.password
}
}]
}
}
});