manual commit 2026-04-10T19:45:00Z
This commit is contained in:
@@ -157,54 +157,10 @@ async function sendTicketClosedEmail(ticket, discordDisplayName) {
|
||||
}
|
||||
}
|
||||
|
||||
// StaffSignature model is registered in models.js; re-import here for use in this file
|
||||
const { mongoose } = require('../db-connection');
|
||||
const StaffSignature = mongoose.model('StaffSignature');
|
||||
|
||||
/**
|
||||
* Get formatted signature blocks (text and HTML) for a staff member
|
||||
* @param {string} userId - Discord user ID
|
||||
* @returns {Promise<{text: string, html: string}>} Signature blocks
|
||||
*/
|
||||
async function getStaffSignatureBlocks(userId) {
|
||||
try {
|
||||
const signature = await StaffSignature.findOne({ userId }).lean();
|
||||
|
||||
if (!signature) {
|
||||
return {
|
||||
text: '',
|
||||
html: ''
|
||||
};
|
||||
}
|
||||
|
||||
const valediction = signature.valediction || '';
|
||||
const displayName = signature.displayName || '';
|
||||
const tagline = signature.tagline || '';
|
||||
|
||||
const textSignature = [
|
||||
valediction,
|
||||
displayName,
|
||||
tagline
|
||||
].filter(Boolean).join('\n');
|
||||
|
||||
const htmlSignature = [
|
||||
valediction ? `<p style="margin: 0;">${escapeHtml(valediction)}</p>` : '',
|
||||
displayName ? `<p style="margin: 0; font-weight: bold;">${escapeHtml(displayName)}</p>` : '',
|
||||
tagline ? `<div style="color: #666; font-size: 12px;">${escapeHtml(tagline)}</div>` : ''
|
||||
].filter(Boolean).join('\n');
|
||||
|
||||
return {
|
||||
text: textSignature,
|
||||
html: htmlSignature
|
||||
};
|
||||
} catch (err) {
|
||||
console.error('Error fetching staff signature:', err);
|
||||
return {
|
||||
text: '',
|
||||
html: ''
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a notification email in the ticket thread (e.g. escalation, high-priority).
|
||||
* @param {Object} ticket - Ticket with gmailThreadId, senderEmail, subject
|
||||
|
||||
Reference in New Issue
Block a user