Skip to content

Commit

Permalink
Tweaks support email layout
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Nov 22, 2024
1 parent 9746a35 commit e0e4831
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/documentation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down
2 changes: 1 addition & 1 deletion app/documentation/questions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
6 changes: 4 additions & 2 deletions app/helper/email/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions app/views/js/contact-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion app/views/partials/contact-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<form id="contact-form" method="POST" style="padding: 0 24px;">
<textarea required name="message" style="min-height: 120px;box-sizing: border-box;border:1px solid #dddddc;border-radius: 5px;width:100%;padding:0.5rem;margin:0.5rem 0"></textarea>
<label style="user-select: none;cursor: pointer;">
<input type="checkbox" name="email" value="yes" style="display: inline;width: auto;margin-right: 6px;">
<input type="checkbox" name="emailToggle" value="yes" style="display: inline;width: auto;margin-right: 6px;">
Include my email so I can be contacted
</label>
<label style="display: none;margin: 6px 0 0;">
Expand Down

0 comments on commit e0e4831

Please sign in to comment.