manual commit 2026-04-10T20:31:52Z
This commit is contained in:
@@ -274,8 +274,8 @@ async function sendGmailReply(
|
|||||||
`Re: ${subject}`
|
`Re: ${subject}`
|
||||||
).toString('base64')}?=`;
|
).toString('base64')}?=`;
|
||||||
const safeUser = escapeHtml(discordUser);
|
const safeUser = escapeHtml(discordUser);
|
||||||
const safeReply = escapeHtml(replyText).replace(/\n/g, '<br>');
|
|
||||||
const safeLogoUrl = escapeHtml(CONFIG.LOGO_URL || '');
|
const safeLogoUrl = escapeHtml(CONFIG.LOGO_URL || '');
|
||||||
|
const companySignatureText = (CONFIG.SIGNATURE || '').replace(/<br>/g, '\n');
|
||||||
|
|
||||||
// Get staff signature if userId provided
|
// Get staff signature if userId provided
|
||||||
let signatureBlocks = { text: '', html: '' };
|
let signatureBlocks = { text: '', html: '' };
|
||||||
@@ -283,41 +283,61 @@ async function sendGmailReply(
|
|||||||
signatureBlocks = await getStaffSignatureBlocks(userId);
|
signatureBlocks = await getStaffSignatureBlocks(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const companySignatureHtml = `
|
const safeStaffSigHtml = signatureBlocks.html ? signatureBlocks.html.replace(/\n/g, '<br>') : '';
|
||||||
<table border="0" cellpadding="0" cellspacing="0">
|
const safeStaffSigText = signatureBlocks.text;
|
||||||
<tr>
|
const safeCompanySigHtml = escapeHtml(CONFIG.SIGNATURE || '').replace(/\n/g, '<br>');
|
||||||
<td style="padding-right: 12px;">
|
|
||||||
${safeLogoUrl ? `<img src="${safeLogoUrl}" width="65">` : ''}
|
|
||||||
</td>
|
|
||||||
<td style="border-left: 1px solid #ddd; padding-left: 12px;">
|
|
||||||
<p style="margin: 0; font-weight: bold;">${safeUser}</p>
|
|
||||||
<div style="color: #666; font-size: 12px;">${escapeHtml(CONFIG.SIGNATURE || '').replace(/\n/g, '<br>')}</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>`;
|
|
||||||
|
|
||||||
const htmlBody = `
|
const htmlBody = `
|
||||||
<div style="font-family: sans-serif; font-size: 14px; color: #333;">
|
<div style="font-family: sans-serif; font-size: 14px; color: #333;">
|
||||||
<p><strong>From:</strong> ${safeUser} on Discord</p>
|
<p>${escapeHtml(replyText).replace(/\n/g, '<br>')}</p>
|
||||||
<p>${safeReply}</p>
|
${safeStaffSigHtml ? `<p style="margin: 10px 0;">${safeStaffSigHtml}</p>` : ''}
|
||||||
${signatureBlocks.html ? `<p style="margin: 10px 0;">${signatureBlocks.html.replace(/\n/g, '<br>')}</p>` : ''}
|
|
||||||
<hr style="border:none; border-top:1px solid #ddd; margin:20px 0;">
|
<hr style="border:none; border-top:1px solid #ddd; margin:20px 0;">
|
||||||
${companySignatureHtml}
|
<table border="0" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td style="padding-right: 12px;">
|
||||||
|
${safeLogoUrl ? `<img src="${safeLogoUrl}" width="65">` : ''}
|
||||||
|
</td>
|
||||||
|
<td style="border-left: 1px solid #ddd; padding-left: 12px;">
|
||||||
|
<p style="margin: 0; font-weight: bold;">${safeUser}</p>
|
||||||
|
<div style="color: #666; font-size: 12px;">${safeCompanySigHtml}</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
const headers = [
|
const boundary = `\000000000000${Date.now().toString(16)}`;
|
||||||
|
|
||||||
|
const plainBody = [];
|
||||||
|
plainBody.push(replyText);
|
||||||
|
if (safeStaffSigText) {
|
||||||
|
plainBody.push(safeStaffSigText);
|
||||||
|
}
|
||||||
|
plainBody.push('');
|
||||||
|
plainBody.push('------------------------------');
|
||||||
|
plainBody.push('');
|
||||||
|
plainBody.push(companySignatureText);
|
||||||
|
|
||||||
|
const raw = Buffer.from([
|
||||||
`From: ${CONFIG.MY_EMAIL}`,
|
`From: ${CONFIG.MY_EMAIL}`,
|
||||||
`To: ${recipientEmail}`,
|
`To: ${recipientEmail}`,
|
||||||
`Subject: ${utf8Subject}`,
|
`Subject: ${utf8Subject}`,
|
||||||
messageId ? `In-Reply-To: ${messageId}` : '',
|
messageId ? `In-Reply-To: ${messageId}` : '',
|
||||||
messageId ? `References: ${messageId}` : '',
|
messageId ? `References: ${messageId}` : '',
|
||||||
'MIME-Version: 1.0',
|
'MIME-Version: 1.0',
|
||||||
|
'Content-Type: multipart/alternative; boundary="' + boundary + '"',
|
||||||
|
'',
|
||||||
|
'--' + boundary,
|
||||||
|
'Content-Type: text/plain; charset="UTF-8"',
|
||||||
|
'',
|
||||||
|
...plainBody,
|
||||||
|
'',
|
||||||
|
'--' + boundary,
|
||||||
'Content-Type: text/html; charset="UTF-8"',
|
'Content-Type: text/html; charset="UTF-8"',
|
||||||
'',
|
'',
|
||||||
htmlBody
|
htmlBody,
|
||||||
].filter(Boolean);
|
'',
|
||||||
|
'--' + boundary + '--'
|
||||||
const raw = Buffer.from(headers.join('\r\n'))
|
].join('\r\n'))
|
||||||
.toString('base64')
|
.toString('base64')
|
||||||
.replace(/\+/g, '-')
|
.replace(/\+/g, '-')
|
||||||
.replace(/\//g, '_')
|
.replace(/\//g, '_')
|
||||||
|
|||||||
Reference in New Issue
Block a user