From f50ae61a866dbcc67a2e545f5ee5212060d9e1f5 Mon Sep 17 00:00:00 2001
From: Andrea
Date: Sun, 27 Feb 2022 09:10:13 +0100
Subject: [PATCH] [mailer] include username in ban and inactivityWarning
---
server/cleanupAccounts.js | 2 +-
server/routes/admin.js | 2 +-
src/mailer.js | 2 ++
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/server/cleanupAccounts.js b/server/cleanupAccounts.js
index 5e7c14ee..01a10762 100644
--- a/server/cleanupAccounts.js
+++ b/server/cleanupAccounts.js
@@ -48,7 +48,7 @@ async function warnInactive(db) {
if (userRefreshed.bannedReason !== null) {
continue;
}
- mailer(userRefreshed.email, 'inactivityWarning')
+ mailer(userRefreshed.email, 'inactivityWarning', {username: userRefreshed.username});
} catch (e) {
console.error(e);
}
diff --git a/server/routes/admin.js b/server/routes/admin.js
index 4570bf01..13d4c884 100644
--- a/server/routes/admin.js
+++ b/server/routes/admin.js
@@ -163,7 +163,7 @@ router.post('/admin/ban/:username', handleErrorAsync(async (req, res) => {
WHERE id = ${user.id}
`);
await archiveBan(req.db, user);
- mailer(user.email, 'ban', {reason: req.body.reason});
+ mailer(user.email, 'ban', {reason: req.body.reason, username: normalise(req.params.username)});
} else {
await req.db.get(SQL`
UPDATE users
diff --git a/src/mailer.js b/src/mailer.js
index f36c2027..82a52364 100644
--- a/src/mailer.js
+++ b/src/mailer.js
@@ -72,6 +72,7 @@ const templates = {
[[ban.header]]
[[ban.reason]][[quotation.colon]] %reason%
[[quotation.start]]${terms}[[quotation.end]]
+ @{{username}}
`,
},
inactivityWarning: {
@@ -84,6 +85,7 @@ const templates = {
[[user.removeInactive.email.cta]]
+ @{{username}}
`,
},
cardsWarning: {