feat: implement template filtering for notifications based on channel type and enhance email rendering with HTML wrapper, ensuring chat messages are sent as plain text

This commit is contained in:
2025-12-01 09:50:53 -03:00
parent d9e78079c8
commit 4c2d12f443
7 changed files with 213 additions and 34 deletions

View File

@@ -170,6 +170,20 @@ async function registrarNotificacoes(
criadaEm: Date.now(),
});
// Se o ticket estiver associado a uma conversa, registrar também uma mensagem de chat
// Isso garante o "duplo canal": email + chat para notificações importantes.
if (ticket.conversaId) {
const conteudoChat = mensagem.length > 0 ? `${titulo}: ${mensagem}` : titulo;
await ctx.db.insert("mensagens", {
conversaId: ticket.conversaId,
remetenteId: usuarioEvento,
tipo: "texto",
conteudo: conteudoChat,
enviadaEm: Date.now(),
});
}
// Notificar responsável (se houver)
if (ticket.responsavelId && ticket.responsavelId !== ticket.solicitanteId) {
const responsavel = await ctx.db.get(ticket.responsavelId);