@dibs-tech/mail-client
Advanced tools
Comparing version 1.5.3 to 1.5.4
43
index.js
@@ -141,35 +141,2 @@ const SparkPost = require('sparkpost'); | ||
/** | ||
* 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 sendCustomTemplatedEmail(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); | ||
}); | ||
} | ||
/** | ||
* sendTemplatedEmail - Description | ||
@@ -187,4 +154,6 @@ * @memberof MailClient | ||
*/ | ||
MailClient.prototype.sendTemplatedEmail = function sendTemplatedEmail(recipient, subject, templateName, data, options, cb) { // eslint-disable-line max-len | ||
const source = fs.readFileSync(path.join(path.resolve('.'), 'email/templates/', `${templateName}.hbs`), 'utf-8'); | ||
MailClient.prototype.sendTemplatedEmail = async function sendTemplatedEmail(recipient, subject, templateName, data, options, cb) { // eslint-disable-line max-len | ||
// check if templateName is a link | ||
const templateIsCustom = isURL(templateName); | ||
const source = templateIsCustom ? (await axios.get(templateName)).data : fs.readFileSync(path.join(path.resolve('.'), 'email/templates/', `${templateName}.hbs`), 'utf-8'); | ||
const template = handlebars.compile(source); | ||
@@ -206,6 +175,2 @@ const html = template(data); | ||
// 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) { | ||
@@ -212,0 +177,0 @@ this.sendEmail('transactions@ondibs.com', subject, message, options, cb); |
{ | ||
"name": "@dibs-tech/mail-client", | ||
"version": "1.5.3", | ||
"version": "1.5.4", | ||
"description": "A mail client implementation, using sparkpost", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
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
9103
6
178