diff --git a/src/controllers/dashBoardController.js b/src/controllers/dashBoardController.js index c9cdbd588..68e88ae58 100644 --- a/src/controllers/dashBoardController.js +++ b/src/controllers/dashBoardController.js @@ -1,6 +1,6 @@ -const mongoose = require("mongoose"); const path = require("path"); const fs = require("fs/promises"); +const mongoose = require("mongoose"); const dashboardhelper = require("../helpers/dashboardhelper")(); const emailSender = require("../utilities/emailSender"); @@ -168,34 +168,45 @@ const dashboardcontroller = function () {

${args[3][item]}

` ); } - const text = `New Suggestion: -

Suggestion Category:

-

${args[0]}

-

Suggestion:

-

${args[1]}

- ${fieldaaray.length > 0 ? fieldaaray : ""} -

Wants Feedback:

-

${args[2]}

-

Thank you,
- One Community

`; + const text = `New Suggestion From ${args[3].firstName} ${ + args[3].lastName + } + : + ⚹ Suggestion Category: +

${args[0]}

+ ⚹ Suggestion: +

${args[1]}

+ ${fieldaaray.length > 0 ? fieldaaray : ""} + ⚹ Name of Suggester: +

${args[3].firstName} ${args[3].lastName}

+ ⚹ Email of Suggester: +

${args[4]}

+ ⚹ Wants Feedback: +

${args[2]}

+ Thank you,
+ One Community
`; return text; }; // send suggestion email const sendMakeSuggestion = async (req, res) => { - const { suggestioncate, suggestion, confirm, ...rest } = req.body; + const { suggestioncate, suggestion, confirm, email, ...rest } = req.body; const emailBody = await getsuggestionEmailBody( suggestioncate, suggestion, confirm, - rest + rest, + email ); try { emailSender( "onecommunityglobal@gmail.com", "A new suggestion", - emailBody + emailBody, + null, + null, + email ); res.status(200).send("Success"); } catch { diff --git a/src/utilities/emailSender.js b/src/utilities/emailSender.js index 4841d1410..b4864add6 100644 --- a/src/utilities/emailSender.js +++ b/src/utilities/emailSender.js @@ -2,7 +2,6 @@ const nodemailer = require('nodemailer'); const { google } = require('googleapis'); const logger = require('../startup/logger'); - const closure = () => { const queue = []; @@ -36,8 +35,8 @@ const closure = () => { if (!nextItem) return; const { - recipient, subject, message, cc, bcc, - } = nextItem; + recipient, subject, message, cc, bcc, replyTo, +} = nextItem; try { // Generate the accessToken on the fly @@ -51,6 +50,7 @@ const closure = () => { bcc, subject, html: message, + replyTo, auth: { user: CLIENT_EMAIL, refreshToken: REFRESH_TOKEN, @@ -65,10 +65,22 @@ const closure = () => { } }, process.env.MAIL_QUEUE_INTERVAL || 1000); - const emailSender = function (recipient, subject, message, cc = null, bcc = null) { + const emailSender = function ( + recipient, + subject, + message, + cc = null, + bcc = null, + replyTo = null, + ) { if (process.env.sendEmail) { queue.push({ - recipient, subject, message, cc, bcc, + recipient, + subject, + message, + cc, + bcc, + replyTo, }); } };