- reapply proper prettier formatting.
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -15,9 +15,9 @@ const moment = require("moment");
|
||||
|
||||
// TODO use InstanceDynamicManager on the footer default to prevent the word IMEX from being hardcoded
|
||||
|
||||
const generateEmailTemplate = (strings) => {
|
||||
const generateEmailTemplate = (strings) => {
|
||||
|
||||
let now = () =>moment().format('MM/DD/YYYY @ hh:mm a');
|
||||
let now = () => moment().format('MM/DD/YYYY @ hh:mm a');
|
||||
|
||||
return `
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
|
||||
@@ -5,13 +5,13 @@ require("dotenv").config({
|
||||
const axios = require("axios");
|
||||
let nodemailer = require("nodemailer");
|
||||
let aws = require("@aws-sdk/client-ses");
|
||||
let { defaultProvider } = require("@aws-sdk/credential-provider-node");
|
||||
let {defaultProvider} = require("@aws-sdk/credential-provider-node");
|
||||
const InstanceManager = require("../utils/instanceMgr").default;
|
||||
const logger = require("../utils/logger");
|
||||
const client = require("../graphql-client/graphql-client").client;
|
||||
const queries = require("../graphql-client/queries");
|
||||
const {isObject} = require("lodash");
|
||||
const generateEmailTemplate = require('./generateTemplate');
|
||||
const generateEmailTemplate = require('./generateTemplate');
|
||||
|
||||
const ses = new aws.SES({
|
||||
// The key apiVersion is no longer supported in v3, and can be removed.
|
||||
@@ -25,10 +25,10 @@ const ses = new aws.SES({
|
||||
});
|
||||
|
||||
let transporter = nodemailer.createTransport({
|
||||
SES: { ses, aws }
|
||||
SES: {ses, aws}
|
||||
});
|
||||
|
||||
exports.sendServerEmail = async function ({ subject, text }) {
|
||||
exports.sendServerEmail = async function ({subject, text}) {
|
||||
if (process.env.NODE_ENV === undefined) return;
|
||||
try {
|
||||
transporter.sendMail(
|
||||
@@ -60,7 +60,7 @@ exports.sendServerEmail = async function ({ subject, text }) {
|
||||
logger.log("server-email-failure", "error", null, null, error);
|
||||
}
|
||||
};
|
||||
exports.sendTaskEmail = async function ({ to, subject, text, attachments }) {
|
||||
exports.sendTaskEmail = async function ({to, subject, text, attachments}) {
|
||||
try {
|
||||
transporter.sendMail(
|
||||
{
|
||||
@@ -125,12 +125,12 @@ exports.sendEmail = async (req, res) => {
|
||||
attachments:
|
||||
[
|
||||
...((req.body.attachments &&
|
||||
req.body.attachments.map((a) => {
|
||||
return {
|
||||
filename: a.filename,
|
||||
path: a.path
|
||||
};
|
||||
})) ||
|
||||
req.body.attachments.map((a) => {
|
||||
return {
|
||||
filename: a.filename,
|
||||
path: a.path
|
||||
};
|
||||
})) ||
|
||||
[]),
|
||||
...downloadedMedia.map((a) => {
|
||||
return {
|
||||
@@ -157,7 +157,7 @@ exports.sendEmail = async (req, res) => {
|
||||
replyTo: req.body.ReplyTo.Email,
|
||||
to: req.body.to,
|
||||
cc: req.body.cc,
|
||||
subject: req.body.subject,
|
||||
subject: req.body.subject,
|
||||
templateStrings: req.body.templateStrings
|
||||
// info,
|
||||
});
|
||||
@@ -186,14 +186,14 @@ exports.sendEmail = async (req, res) => {
|
||||
subject: req.body.subject,
|
||||
bodyshopid: req.body.bodyshopid
|
||||
});
|
||||
res.status(500).json({ success: false, error: err });
|
||||
res.status(500).json({success: false, error: err});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
async function getImage(imageUrl) {
|
||||
let image = await axios.get(imageUrl, { responseType: "arraybuffer" });
|
||||
let image = await axios.get(imageUrl, {responseType: "arraybuffer"});
|
||||
let raw = Buffer.from(image.data).toString("base64");
|
||||
return "data:" + image.headers["content-type"] + ";base64," + raw;
|
||||
}
|
||||
@@ -281,10 +281,10 @@ exports.emailBounce = async function (req, res) {
|
||||
})} has tried to deliver an email with the subject: ${subject} to the intended recipients but encountered an error.
|
||||
|
||||
${body.bounce?.bouncedRecipients.map(
|
||||
(r) =>
|
||||
`Recipient: ${r.emailAddress} | Status: ${r.action} | Code: ${r.diagnosticCode}
|
||||
(r) =>
|
||||
`Recipient: ${r.emailAddress} | Status: ${r.action} | Code: ${r.diagnosticCode}
|
||||
`
|
||||
)}
|
||||
)}
|
||||
`
|
||||
},
|
||||
(err, info) => {
|
||||
|
||||
Reference in New Issue
Block a user