From e0e48319a889584add9f9659953fa97d1ef4f2d7 Mon Sep 17 00:00:00 2001 From: David Merfield Date: Fri, 22 Nov 2024 11:33:36 +0100 Subject: [PATCH] Tweaks support email layout --- app/documentation/index.js | 2 +- app/documentation/questions/index.js | 2 +- app/helper/email/index.js | 6 ++++-- app/views/js/contact-form.js | 4 ++-- app/views/partials/contact-form.html | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/documentation/index.js b/app/documentation/index.js index f00d65a1023..97733eccb1a 100644 --- a/app/documentation/index.js +++ b/app/documentation/index.js @@ -89,7 +89,7 @@ documentation.post(['/support', '/contact', '/feedback'], (req, res) => { const { email, message } = req.body; if (!message) return res.status(400).send('Message is required'); - Email.SUPPORT(null, { email, message }); + Email.SUPPORT(null, { email, message, replyTo: email }); res.send('OK'); }); diff --git a/app/documentation/questions/index.js b/app/documentation/questions/index.js index 6b57275ded8..5be8640fef1 100644 --- a/app/documentation/questions/index.js +++ b/app/documentation/questions/index.js @@ -223,7 +223,7 @@ Questions.route("/ask") // to manually post the question if (!req.session || !req.session.uid) { const questionURL = config.protocol + config.host + "/sites/log-in?then=" + encodeURIComponent("/questions/ask?title=" + encodeURIComponent(title) + "&body=" + encodeURIComponent(body)); - Email.QUESTION(null, { title, body, questionURL, email }); + Email.QUESTION(null, { title, body, questionURL, email, replyTo: email }); res.send("OK"); } else { const { id } = await create({ author, title, body, tags }); diff --git a/app/helper/email/index.js b/app/helper/email/index.js index 12074c1be72..5cb17feb1a8 100644 --- a/app/helper/email/index.js +++ b/app/helper/email/index.js @@ -88,7 +88,8 @@ var EMAIL_MODEL = { to: "string", from: "string", subject: "string", - html: "string" + html: "string", + "h:Reply-To": "string" }; function loadUser (uid, callback) { @@ -152,7 +153,8 @@ function send (locals, messageFile, to, callback) { html: html, subject: subject, from: locals.from || FROM, - to: to + to: to, + 'h:Reply-To': locals.replyTo || locals.from || FROM }; try { diff --git a/app/views/js/contact-form.js b/app/views/js/contact-form.js index af1c29c5f20..ec5c9d115d6 100644 --- a/app/views/js/contact-form.js +++ b/app/views/js/contact-form.js @@ -3,7 +3,7 @@ const contactForm = document.getElementById('contact-form'); if (contactForm) { // when the email checkbox is checked, show the email input -contactForm.querySelector('input[type="checkbox"][name="email"]').addEventListener('change', function(e) { +contactForm.querySelector('input[type="checkbox"][name="emailToggle"]').addEventListener('change', function(e) { var emailInput = document.querySelector('input[type="email"]'); emailInput.parentElement.style.display = e.target.checked ? 'block' : 'none'; // focus the email input if it's shown @@ -13,7 +13,7 @@ contactForm.querySelector('input[type="checkbox"][name="email"]').addEventListen }); // if the input is checked on page load, show the email input -if (contactForm.querySelector('input[type="checkbox"][name="email"]').checked) { +if (contactForm.querySelector('input[type="checkbox"][name="emailToggle"]').checked) { contactForm.querySelector('input[type="email"]').parentElement.style.display = 'block'; } diff --git a/app/views/partials/contact-form.html b/app/views/partials/contact-form.html index 6fecc0bb835..f51641b94b4 100644 --- a/app/views/partials/contact-form.html +++ b/app/views/partials/contact-form.html @@ -2,7 +2,7 @@