Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// but we really don't need to support cid
//
message.text = htmlToText.fromString(
message.html,
this.config.htmlToText
);
// if we only want a text-based version of the email
if (this.config.textOnly) delete message.html;
// if no subject, html, or text content exists then we should
// throw an error that says at least one must be found
// otherwise the email would be blank (defeats purpose of email-templates)
if (
(!is.string(message.subject) ||
is.emptyStringOrWhitespace(message.subject)) &&
(!is.string(message.text) || is.emptyStringOrWhitespace(message.text)) &&
(!is.string(message.html) || is.emptyStringOrWhitespace(message.html)) &&
_.isArray(message.attachments) &&
_.isEmpty(message.attachments)
)
throw new Error(
`No content was passed for subject, html, text, nor attachments message props. Check that the files for the template "${template}" exist.`
);
return message;
}
//
message.text = htmlToText.fromString(
message.html,
this.config.htmlToText
);
// if we only want a text-based version of the email
if (this.config.textOnly) delete message.html;
// if no subject, html, or text content exists then we should
// throw an error that says at least one must be found
// otherwise the email would be blank (defeats purpose of email-templates)
if (
(!is.string(message.subject) ||
is.emptyStringOrWhitespace(message.subject)) &&
(!is.string(message.text) || is.emptyStringOrWhitespace(message.text)) &&
(!is.string(message.html) || is.emptyStringOrWhitespace(message.html)) &&
_.isArray(message.attachments) &&
_.isEmpty(message.attachments)
)
throw new Error(
`No content was passed for subject, html, text, nor attachments message props. Check that the files for the template "${template}" exist.`
);
return message;
}
message.text = htmlToText.fromString(
message.html,
this.config.htmlToText
);
// if we only want a text-based version of the email
if (this.config.textOnly) delete message.html;
// if no subject, html, or text content exists then we should
// throw an error that says at least one must be found
// otherwise the email would be blank (defeats purpose of email-templates)
if (
(!is.string(message.subject) ||
is.emptyStringOrWhitespace(message.subject)) &&
(!is.string(message.text) || is.emptyStringOrWhitespace(message.text)) &&
(!is.string(message.html) || is.emptyStringOrWhitespace(message.html)) &&
_.isArray(message.attachments) &&
_.isEmpty(message.attachments)
)
throw new Error(
`No content was passed for subject, html, text, nor attachments message props. Check that the files for the template "${template}" exist.`
);
return message;
}