Chat: Kunde bekommt Mail, wenn das Team schreibt (K17)
Neue Vorlage K17 im Stil von K16 mit Nachricht, Absender und Link auf den Portal-Chat. Hoechstens eine Mail je Kunde im Zeitfenster CHAT_NOTIFY_THROTTLE_MIN (15 Min.), ohne BCC ans Team, nicht ohne E-Mail-Adresse oder Portalzugang. Das Admin-Panel zeigt unter dem Kundennamen, ob der Hinweis rausging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
37489aa866
commit
00ea4baf65
6 files changed
+176
-7
No files matched your search
@@ -17,7 +17,9 @@ import { listAppointments, saveAppointment } from '../services/appointments.js'
|
||||
import { getCustomerActivity } from '../services/customerActivity.js'
|
||||
import { listInvoicesForClient } from '../services/invoiceNinja.js'
|
||||
import { prepareMessage, rawUpload, sanitizeMessage, uploadErrors } from './chat.js'
|
||||
import { sendCustomerChatNotice } from '../services/mailer.js'
|
||||
import {
|
||||
attachmentLines,
|
||||
attachmentSummary,
|
||||
deletePendingAttachment,
|
||||
messageAttachments,
|
||||
@@ -393,7 +395,14 @@ router.post('/chats/:customerId/messages', async (req, res) => {
|
||||
ID.unique()
|
||||
)
|
||||
await prepared.claim.commit(doc.$id)
|
||||
return res.status(201).json({ message: sanitizeMessage(doc) })
|
||||
|
||||
// Kunden per Mail hinweisen (K17, gedrosselt); Fehler lassen die Nachricht bestehen
|
||||
const lines = attachmentLines(prepared.claim.attachments)
|
||||
const notice = await sendCustomerChatNotice(customer, {
|
||||
sender: doc.senderName,
|
||||
text: [prepared.text, lines.length ? `Anhänge:\n${lines.join('\n')}` : ''].filter(Boolean).join('\n\n'),
|
||||
})
|
||||
return res.status(201).json({ message: sanitizeMessage(doc), notice })
|
||||
} catch (err) {
|
||||
await prepared?.claim.release()
|
||||
return res.status(err.status || 500).json({ error: err.message || 'Nachricht konnte nicht gesendet werden' })
|
||||
|
||||
Reference in new issue
Block a user