@dibs-tech/mail-client
Advanced tools
Comparing version 1.5.0 to 1.5.1
43
index.js
@@ -5,2 +5,3 @@ const SparkPost = require('sparkpost'); | ||
const path = require('path'); | ||
const axios = require('axios'); | ||
@@ -140,3 +141,35 @@ require('./helpers/handlebars/classOrClasses')(handlebars); | ||
/** | ||
* sendCustomTemplatedEmail - Description | ||
* @memberof MailClient | ||
* @instance | ||
* @param {string} recipient the recip | ||
* @param {string} subject the subject | ||
* @param {string} templateLink the stored template link from S3 | ||
* @param {object} data the data | ||
* @param {object} options the options | ||
* @param {MailClient~primaryCallback} cb the callback | ||
* | ||
* @returns {undefined} | ||
*/ | ||
MailClient.prototype.sendCustomTemplatedEmail = function(recipient, subject, templateLink, data, options, cb) { | ||
axios | ||
.get(templateLink) | ||
.then((result) => { | ||
let optionsObj; | ||
const template = handlebars.compile(result.data); | ||
const html = template(data); | ||
if (typeof options === 'function') { | ||
cb = options; | ||
optionsObj = { html }; | ||
} else { | ||
optionsObj = { force: typeof options === 'boolean' ? options : (options.force || false), html }; | ||
if (typeof options !== 'boolean' && options.attachments) optionsObj.attachments = options.attachments; | ||
} | ||
this.sendEmail(recipient, subject, '', optionsObj, cb); | ||
}); | ||
} | ||
/** | ||
@@ -155,3 +188,5 @@ * sendTemplatedEmail - Description | ||
*/ | ||
MailClient.prototype.sendTemplatedEmail = function sendTemplatedEmail(recepient, subject, templateName, data, options, cb) { // eslint-disable-line max-len | ||
MailClient.prototype.sendTemplatedEmail = function sendTemplatedEmail(recipient, subject, templateLink, data, options, cb) { // eslint-disable-line max-len | ||
if (isCustomTemplate) return this.sendCustomTemplatedEmail(recipient, subject, templateLink, data, options, cb); | ||
const source = fs.readFileSync(path.join(path.resolve('.'), 'email/templates/', `${templateName}.hbs`), 'utf-8'); | ||
@@ -171,5 +206,9 @@ const template = handlebars.compile(source); | ||
this.sendEmail(recepient, subject, '', optionsObj, cb); | ||
this.sendEmail(recipient, subject, '', optionsObj, cb); | ||
}; | ||
// MailClient.prototype.sendCustomTemplatedEmail = async function sendCustomTemplatedEmail(recipient, subject, templateLink, data, options) { | ||
// const template = await axios.get(templateLink); | ||
// } | ||
MailClient.prototype.transactions = function transactions(subject, message, options, cb) { | ||
@@ -176,0 +215,0 @@ this.sendEmail('transactions@ondibs.com', subject, message, options, cb); |
{ | ||
"name": "@dibs-tech/mail-client", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "A mail client implementation, using sparkpost", | ||
@@ -12,2 +12,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"axios": "^0.17.1", | ||
"fs": "0.0.1-security", | ||
@@ -14,0 +15,0 @@ "handlebars": "^4.0.6", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8950
194
5
1
+ Addedaxios@^0.17.1
+ Addedaxios@0.17.1(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedis-buffer@1.1.6(transitive)