// src/modules/watchdog/model/email.model.js function prepareNotificationPayload(tickets) { return { subject: buildSubject(tickets), bodyEmail: buildBodyEmail(tickets), recipients: getRecipients(), cc: getCc() }; } function buildSubject(tickets) { if (tickets.length === 0) { return '[GOLEIRO] Nenhum chamado foi agarrado'; } return `🧤 [GOLEIRO] ${tickets.length} chamados foram agarrados`; } function buildBodyEmail(tickets) { let body = `
🚨 Atenção!
O goleiro defendeu os seguintes chamados:
Esses chamados foram fechados no Hubsoft, mas ainda constam como abertos no GLPI.
âš½ Favor verificar e alinhar os status no GLPI.
Watchdog Hub × GLPI
`; return body; } function formatDate(date) { try { return new Date(date).toLocaleString('pt-BR'); } catch { return date; } } function getRecipients() { return process.env.WATCHDOG_RECIPIENT_EMAILS?.split(',') || []; } function getCc() { return process.env.WATCHDOG_CC_EMAILS?.split(',') || []; } module.exports = { prepareNotificationPayload };