Make customer upload-confirmation email opt-out via settings

New smtp_notify_customer toggle in the SMTP section. Defaults to true
to preserve existing behavior. When unchecked, customers no longer
receive the upload summary even if they have an email on file; staff
and (optionally) admins keep getting their notifications.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Hacker 2026-04-16 13:52:39 +02:00
parent 20e61aa61c
commit 2b1417ccf3
3 changed files with 13 additions and 1 deletions

View File

@ -379,6 +379,12 @@
<div><label>Absender (From)</label><input name="smtp_from" placeholder="noreply@firma.de" /></div>
</div>
<div class="field" style="margin-top:.75rem">
<label style="display:flex; align-items:center; gap:.4rem">
<input type="checkbox" name="smtp_notify_customer" style="width:auto" />
Kunden nach Upload eine Bestätigungsmail schicken (nur wenn E-Mail beim Kunden hinterlegt)
</label>
</div>
<div class="field" style="margin-top:.5rem">
<label style="display:flex; align-items:center; gap:.4rem">
<input type="checkbox" name="smtp_notify_admin" style="width:auto" />
Admins bei jedem Upload benachrichtigen (alle Admins mit E-Mail-Adresse)
@ -765,6 +771,7 @@ async function loadSettings() {
? 'gesetzt — leer = unverändert lassen'
: 'nicht gesetzt';
sf.smtp_notify_admin.checked = !!s.smtp_notify_admin;
sf.smtp_notify_customer.checked = s.smtp_notify_customer !== false;
}
function setSlider(id, val) {
document.getElementById(id).value = val;
@ -819,6 +826,7 @@ document.getElementById('smtpForm').addEventListener('submit', async (e) => {
smtp_user: fd.get('smtp_user') || '',
smtp_from: fd.get('smtp_from') || '',
smtp_notify_admin: !!fd.get('smtp_notify_admin'),
smtp_notify_customer: !!fd.get('smtp_notify_customer'),
};
const pw = fd.get('smtp_pass');
if (pw) body.smtp_pass = pw;

View File

@ -272,6 +272,7 @@ api.get('/settings', auth.requireAdmin, (req, res) => {
smtp_pass_set: !!settings.get('smtp_pass', ''),
smtp_from: settings.get('smtp_from', ''),
smtp_notify_admin: settings.get('smtp_notify_admin', 'false') === 'true',
smtp_notify_customer: settings.get('smtp_notify_customer', 'true') === 'true',
});
});
@ -301,6 +302,8 @@ api.put('/settings', auth.requireAdmin, (req, res) => {
if (b.smtp_from !== undefined) settings.set('smtp_from', String(b.smtp_from || '').trim());
if (b.smtp_notify_admin !== undefined)
settings.set('smtp_notify_admin', b.smtp_notify_admin ? 'true' : 'false');
if (b.smtp_notify_customer !== undefined)
settings.set('smtp_notify_customer', b.smtp_notify_customer ? 'true' : 'false');
res.json({ ok: true });
});

View File

@ -15,7 +15,8 @@ function fmtSize(n) {
function recipientsFor(customer) {
const out = [];
if (customer.email) out.push({ kind: 'customer', to: customer.email });
const notifyCustomer = settings.get('smtp_notify_customer', 'true') === 'true';
if (notifyCustomer && customer.email) out.push({ kind: 'customer', to: customer.email });
// Staff assigned to this customer (with email)
const staff = db.prepare(`