/** * Refresh the ticket-created system email template with richer branding details. */ exports.up = async function(knex) { const template = await knex('system_email_templates') .where({ name: 'ticket-created' }) .first(); if (!template) { return; } const updatedSubject = 'New Ticket • {{ticket.title}} ({{ticket.priority}})'; const updatedHtmlContent = `
New Ticket Created
{{ticket.title}}
{{ticket.metaLine}}

A new ticket has been logged for {{ticket.companyName}}. Review the summary below and follow the link to take action.

Ticket #{{ticket.id}}
Priority {{ticket.priority}}
Status {{ticket.status}}
Created {{ticket.createdAt}} · {{ticket.createdBy}}
Assigned To
{{ticket.assignedToName}}
{{ticket.assignedToEmail}}
Requester
{{ticket.requesterName}}
{{ticket.requesterContact}}
Channel {{ticket.channel}}
Category {{ticket.categoryDetails}}
Location {{ticket.locationSummary}}
Description
{{ticket.description}}
View Ticket
Powered by Alga PSA • Keeping teams aligned
`; const updatedTextContent = ` New Ticket Created for {{ticket.companyName}} {{ticket.metaLine}} Created: {{ticket.createdAt}} · {{ticket.createdBy}} Priority: {{ticket.priority}} Status: {{ticket.status}} Assigned To: {{ticket.assignedDetails}} Requester: {{ticket.requesterDetails}} Channel: {{ticket.channel}} Category: {{ticket.categoryDetails}} Location: {{ticket.locationSummary}} Description: {{ticket.description}} View ticket: {{ticket.url}} `; await knex('system_email_templates') .where({ id: template.id }) .update({ subject: updatedSubject, html_content: updatedHtmlContent, text_content: updatedTextContent, updated_at: knex.fn.now() }); }; exports.down = async function(knex) { const template = await knex('system_email_templates') .where({ name: 'ticket-created' }) .first(); if (!template) { return; } const originalSubject = 'New Ticket: {{ticket.title}}'; const originalHtmlContent = `

New Ticket Created

A new ticket has been created in your PSA system:

Ticket ID: {{ticket.id}}

Title: {{ticket.title}}

Description: {{ticket.description}}

Priority: {{ticket.priority}}

Status: {{ticket.status}}

View Ticket `; const originalTextContent = ` New Ticket Created A new ticket has been created in your PSA system: Ticket ID: {{ticket.id}} Title: {{ticket.title}} Description: {{ticket.description}} Priority: {{ticket.priority}} Status: {{ticket.status}} View ticket at: {{ticket.url}} `; await knex('system_email_templates') .where({ id: template.id }) .update({ subject: originalSubject, html_content: originalHtmlContent, text_content: originalTextContent, updated_at: knex.fn.now() }); };