mvp: neuter debug log helpers, strip config keys, update tagline
This commit is contained in:
@@ -110,11 +110,7 @@ const CONFIG = {
|
|||||||
ADMIN_ID: process.env.ADMIN_ID || null,
|
ADMIN_ID: process.env.ADMIN_ID || null,
|
||||||
FORCE_CLOSE_TIMER: toInt(process.env.FORCE_CLOSE_TIMER_SECONDS, 60),
|
FORCE_CLOSE_TIMER: toInt(process.env.FORCE_CLOSE_TIMER_SECONDS, 60),
|
||||||
GMAIL_POLL_INTERVAL_MS: toInt(process.env.GMAIL_POLL_INTERVAL_SECONDS, 30) * 1000,
|
GMAIL_POLL_INTERVAL_MS: toInt(process.env.GMAIL_POLL_INTERVAL_SECONDS, 30) * 1000,
|
||||||
GMAIL_LOG_CHANNEL_ID: process.env.GMAIL_LOG_CHANNEL_ID || null,
|
|
||||||
AUTOMATION_LOG_CHANNEL_ID: process.env.AUTOMATION_LOG_CHANNEL_ID || null,
|
|
||||||
RENAME_LOG_CHANNEL_ID: process.env.RENAME_LOG_CHANNEL_ID || null,
|
RENAME_LOG_CHANNEL_ID: process.env.RENAME_LOG_CHANNEL_ID || null,
|
||||||
SECURITY_LOG_CHANNEL_ID: process.env.SECURITY_LOG_CHANNEL_ID || null,
|
|
||||||
SYSTEM_LOG_CHANNEL_ID: process.env.SYSTEM_LOG_CHANNEL_ID || null,
|
|
||||||
STAFF_THREAD_ENABLED: process.env.STAFF_THREAD_ENABLED === 'true',
|
STAFF_THREAD_ENABLED: process.env.STAFF_THREAD_ENABLED === 'true',
|
||||||
STAFF_THREAD_NAME: process.env.STAFF_THREAD_NAME || 'Staff Discussion',
|
STAFF_THREAD_NAME: process.env.STAFF_THREAD_NAME || 'Staff Discussion',
|
||||||
STAFF_THREAD_AUTO_ADD_ROLE: process.env.STAFF_THREAD_AUTO_ADD_ROLE === 'true',
|
STAFF_THREAD_AUTO_ADD_ROLE: process.env.STAFF_THREAD_AUTO_ADD_ROLE === 'true',
|
||||||
|
|||||||
@@ -123,12 +123,15 @@ async function runEscalation(interaction, ticket, nextTier, reason) {
|
|||||||
|
|
||||||
if (!isDiscordTicket && ticket.gmailThreadId) {
|
if (!isDiscordTicket && ticket.gmailThreadId) {
|
||||||
try {
|
try {
|
||||||
const emailBody = CONFIG.ESCALATION_MESSAGE.replace(/\\n/g, '\n').replace(/\{support_name\}/g, CONFIG.SUPPORT_NAME);
|
const escalatorName = interaction.member?.displayName || interaction.user.username;
|
||||||
|
const tierLabel = nextTier === 1 ? 'tier 2' : 'tier 3';
|
||||||
|
const emailBody = `${escalatorName} escalated this ticket to ${tierLabel}.${reason ? `\n\nReason: ${reason}` : ''}`;
|
||||||
await sendTicketNotificationEmail(
|
await sendTicketNotificationEmail(
|
||||||
ticket,
|
ticket,
|
||||||
`Ticket escalated to ${nextTier === 1 ? 'tier 2' : 'tier 3'}`,
|
null,
|
||||||
emailBody,
|
emailBody,
|
||||||
interaction.member?.displayName || interaction.user.username
|
escalatorName,
|
||||||
|
interaction.user.id
|
||||||
);
|
);
|
||||||
} catch (emailErr) {
|
} catch (emailErr) {
|
||||||
console.error('Escalation email failed (non-fatal):', emailErr.message);
|
console.error('Escalation email failed (non-fatal):', emailErr.message);
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ const ALLOWED_CONFIG_KEYS = new Set([
|
|||||||
// Channel IDs
|
// Channel IDs
|
||||||
'TRANSCRIPT_CHANNEL_ID', 'LOGGING_CHANNEL_ID', 'DEBUGGING_CHANNEL_ID',
|
'TRANSCRIPT_CHANNEL_ID', 'LOGGING_CHANNEL_ID', 'DEBUGGING_CHANNEL_ID',
|
||||||
'DISCORD_CHANNEL_ID',
|
'DISCORD_CHANNEL_ID',
|
||||||
'GMAIL_LOG_CHANNEL_ID', 'AUTOMATION_LOG_CHANNEL_ID', 'RENAME_LOG_CHANNEL_ID',
|
'RENAME_LOG_CHANNEL_ID',
|
||||||
'SECURITY_LOG_CHANNEL_ID', 'SYSTEM_LOG_CHANNEL_ID',
|
|
||||||
// Messages and labels
|
// Messages and labels
|
||||||
'ESCALATION_MESSAGE', 'TICKET_CLOSE_SUBJECT_PREFIX', 'TICKET_CLOSE_MESSAGE', 'TICKET_CLOSE_SIGNATURE',
|
'ESCALATION_MESSAGE', 'TICKET_CLOSE_SUBJECT_PREFIX', 'TICKET_CLOSE_MESSAGE', 'TICKET_CLOSE_SIGNATURE',
|
||||||
'DISCORD_CLOSE_MESSAGE', 'DISCORD_TRANSCRIPT_MESSAGE', 'DISCORD_AUTO_CLOSE_MESSAGE',
|
'DISCORD_CLOSE_MESSAGE', 'DISCORD_TRANSCRIPT_MESSAGE', 'DISCORD_AUTO_CLOSE_MESSAGE',
|
||||||
|
|||||||
@@ -81,51 +81,15 @@ async function logTicketEvent(action, fields, interaction = null) {
|
|||||||
|
|
||||||
// --- logGmail ---
|
// --- logGmail ---
|
||||||
|
|
||||||
async function logGmail(subject, sender, ticketNumber, game) {
|
async function logGmail(...args) { return; }
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setTitle('Email Ticket Created')
|
|
||||||
.setColor(0x00BFFF)
|
|
||||||
.addFields(
|
|
||||||
{ name: 'Subject', value: String(subject || 'No subject').slice(0, 256), inline: false },
|
|
||||||
{ name: 'Sender', value: String(sender || 'unknown'), inline: true },
|
|
||||||
{ name: 'Ticket #', value: String(ticketNumber || '?'), inline: true },
|
|
||||||
{ name: 'Game', value: String(game || 'Not detected'), inline: true }
|
|
||||||
)
|
|
||||||
.setTimestamp();
|
|
||||||
await sendToChannel(CONFIG.GMAIL_LOG_CHANNEL_ID, embed);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- logAutomation ---
|
// --- logAutomation ---
|
||||||
|
|
||||||
async function logAutomation(action, ticketChannelName, detail) {
|
async function logAutomation(...args) { return; }
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setTitle(action)
|
|
||||||
.setColor(0x9B59B6)
|
|
||||||
.setTimestamp();
|
|
||||||
if (ticketChannelName) {
|
|
||||||
embed.addFields({ name: 'Ticket', value: String(ticketChannelName), inline: true });
|
|
||||||
}
|
|
||||||
if (detail) {
|
|
||||||
embed.addFields({ name: 'Detail', value: String(detail).slice(0, 1024), inline: false });
|
|
||||||
}
|
|
||||||
await sendToChannel(CONFIG.AUTOMATION_LOG_CHANNEL_ID, embed);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- logSecurity ---
|
// --- logSecurity ---
|
||||||
|
|
||||||
async function logSecurity(action, user, detail, overrideClient = null, color = 0xFF6600) {
|
async function logSecurity(...args) { return; }
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setTitle('Security Event')
|
|
||||||
.setColor(color)
|
|
||||||
.addFields(
|
|
||||||
{ name: 'Action', value: String(action).slice(0, 256), inline: false },
|
|
||||||
{ name: 'User', value: user ? `${user.tag} (${user.id})` : 'Unknown', inline: true },
|
|
||||||
{ name: 'Detail', value: String(detail || 'N/A').slice(0, 1024), inline: false },
|
|
||||||
{ name: 'Timestamp', value: new Date().toISOString(), inline: true }
|
|
||||||
)
|
|
||||||
.setTimestamp();
|
|
||||||
await sendToChannel(CONFIG.SECURITY_LOG_CHANNEL_ID, embed, overrideClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- logIntegrity ---
|
// --- logIntegrity ---
|
||||||
|
|
||||||
@@ -144,17 +108,7 @@ async function logIntegrity(issue, detail, overrideClient = null) {
|
|||||||
|
|
||||||
// --- logSystem ---
|
// --- logSystem ---
|
||||||
|
|
||||||
async function logSystem(message, fields = [], overrideClient = null, color = 0x0099ff) {
|
async function logSystem(...args) { return; }
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setTitle(message)
|
|
||||||
.setColor(color)
|
|
||||||
.setTimestamp();
|
|
||||||
if (fields.length > 0) {
|
|
||||||
embed.addFields(fields.map(f => ({ name: f.name, value: String(f.value).slice(0, 1024), inline: f.inline ?? true })));
|
|
||||||
}
|
|
||||||
embed.addFields({ name: 'Timestamp', value: new Date().toISOString(), inline: true });
|
|
||||||
await sendToChannel(CONFIG.SYSTEM_LOG_CHANNEL_ID, embed, overrideClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setClient,
|
setClient,
|
||||||
|
|||||||
@@ -11,6 +11,35 @@ const { readEnvFile } = require('./configPersistence');
|
|||||||
function sanitizeHeaderValue(v) { return String(v || '').replace(/[\r\n]+/g, ' ').trim(); }
|
function sanitizeHeaderValue(v) { return String(v || '').replace(/[\r\n]+/g, ' ').trim(); }
|
||||||
const EMAIL_RE = /^[^@\s]+@[^@\s]+$/;
|
const EMAIL_RE = /^[^@\s]+@[^@\s]+$/;
|
||||||
|
|
||||||
|
function buildCompanySigHtml() {
|
||||||
|
const safeLogoUrl = escapeHtml(CONFIG.LOGO_URL || '');
|
||||||
|
return `
|
||||||
|
<table border="0" cellpadding="0" cellspacing="0" style="margin-top: 16px;">
|
||||||
|
<tr>
|
||||||
|
<td style="padding-right: 12px; vertical-align: top;">
|
||||||
|
${safeLogoUrl ? `<img src="${safeLogoUrl}" width="65" alt="Indifferent Broccoli">` : ''}
|
||||||
|
</td>
|
||||||
|
<td style="border-left: 1px solid #ddd; padding-left: 12px; vertical-align: top; font-size: 13px; color: #333;">
|
||||||
|
Indifferent Broccoli Support<br>
|
||||||
|
<a href="https://indifferentbroccoli.com/">https://indifferentbroccoli.com/</a><br>
|
||||||
|
Join us on <a href="https://discord.gg/2vmfrrtvJY">Discord</a><br>
|
||||||
|
<br>
|
||||||
|
<em>Host your own game server. Or not... we don't care.</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildCompanySigText() {
|
||||||
|
return [
|
||||||
|
'Indifferent Broccoli Support',
|
||||||
|
'https://indifferentbroccoli.com/',
|
||||||
|
'Join us on Discord: https://discord.gg/2vmfrrtvJY',
|
||||||
|
'',
|
||||||
|
"Host your own game server. Or not... we don't care."
|
||||||
|
].join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
function getGmailClient() {
|
function getGmailClient() {
|
||||||
const auth = new google.auth.OAuth2(
|
const auth = new google.auth.OAuth2(
|
||||||
process.env.GOOGLE_CLIENT_ID,
|
process.env.GOOGLE_CLIENT_ID,
|
||||||
@@ -154,7 +183,7 @@ async function sendTicketNotificationEmail(ticket, subjectLine, messageBody, fro
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let subjectHeader = ticket.subject || 'Support';
|
let originalSubject = null;
|
||||||
let msgId = null;
|
let msgId = null;
|
||||||
try {
|
try {
|
||||||
const thread = await gmail.users.threads.get({
|
const thread = await gmail.users.threads.get({
|
||||||
@@ -162,67 +191,75 @@ async function sendTicketNotificationEmail(ticket, subjectLine, messageBody, fro
|
|||||||
id: ticket.gmailThreadId
|
id: ticket.gmailThreadId
|
||||||
});
|
});
|
||||||
const messages = thread.data.messages || [];
|
const messages = thread.data.messages || [];
|
||||||
const lastMsg = [...messages].reverse()[0];
|
const firstMsg = messages[0];
|
||||||
if (lastMsg?.payload?.headers) {
|
if (firstMsg?.payload?.headers) {
|
||||||
const subj = lastMsg.payload.headers.find(h => h.name === 'Subject')?.value;
|
const subj = firstMsg.payload.headers.find(h => h.name === 'Subject')?.value;
|
||||||
if (subj) subjectHeader = subj;
|
if (subj) originalSubject = subj;
|
||||||
msgId = sanitizeHeaderValue(lastMsg.payload.headers.find(h => h.name === 'Message-ID')?.value);
|
msgId = sanitizeHeaderValue(firstMsg.payload.headers.find(h => h.name === 'Message-ID')?.value);
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
||||||
const finalSubject = sanitizeHeaderValue(subjectLine || subjectHeader);
|
// Thread-safety: derive Subject from the last thread message; strip any leading
|
||||||
const utf8Subject = `=?utf-8?B?${Buffer.from(finalSubject).toString('base64')}?=`;
|
// Re:/RE:/Re : variants and re-prepend a single "Re: ". Fall back to subjectLine
|
||||||
const label = escapeHtml(fromLabel || CONFIG.SUPPORT_NAME || 'Support');
|
// (legacy param) only if the thread lookup gave us nothing.
|
||||||
const safeBody = escapeHtml(messageBody || '').replace(/\n/g, '<br>');
|
const baseSubject = originalSubject || subjectLine || ticket.subject || 'Support';
|
||||||
const safeLogoUrl = escapeHtml(CONFIG.LOGO_URL || '');
|
const stripped = String(baseSubject).replace(/^(?:\s*Re\s*:\s*)+/i, '');
|
||||||
|
const safeSubject = sanitizeHeaderValue(`Re: ${stripped}`);
|
||||||
// Get staff signature if userId provided
|
const utf8Subject = `=?utf-8?B?${Buffer.from(safeSubject).toString('base64')}?=`;
|
||||||
|
|
||||||
let signatureBlocks = { text: '', html: '' };
|
let signatureBlocks = { text: '', html: '' };
|
||||||
if (userId) {
|
if (userId) {
|
||||||
signatureBlocks = await getStaffSignatureBlocks(userId);
|
signatureBlocks = await getStaffSignatureBlocks(userId);
|
||||||
}
|
}
|
||||||
|
// signatureBlocks.html arrives pre-escaped from getStaffSignatureBlocks.
|
||||||
const safeSignature = escapeHtml(CONFIG.SIGNATURE || '').replace(/\n/g, '<br>');
|
const safeStaffSigHtml = signatureBlocks.html ? signatureBlocks.html.replace(/\n/g, '<br>') : '';
|
||||||
const serverDisplayName = label;
|
const safeStaffSigText = signatureBlocks.text;
|
||||||
const safeCloseMessage = safeBody;
|
|
||||||
const safeCloseSignature = escapeHtml(CONFIG.TICKET_CLOSE_SIGNATURE || '').replace(/\n/g, '<br>');
|
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> ${serverDisplayName} on Discord</p>
|
<p>${escapeHtml(messageBody || '').replace(/\n/g, '<br>')}</p>
|
||||||
<p><strong>Message:</strong></p>
|
${safeStaffSigHtml ? `<p style="margin: 10px 0;">${safeStaffSigHtml}</p>` : ''}
|
||||||
<p>${safeCloseMessage}</p>
|
${buildCompanySigHtml()}
|
||||||
<p style="margin-top: 16px;">${safeCloseSignature}</p>
|
|
||||||
<hr style="border:none; border-top:1px solid #ddd; margin:20px 0;">
|
|
||||||
<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;">${serverDisplayName}</p>
|
|
||||||
<div style="color: #666; font-size: 12px;">${safeSignature}</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
const rawHeaders = [
|
const boundary = '000000000000' + Date.now().toString(16);
|
||||||
|
|
||||||
|
const plainBody = [];
|
||||||
|
plainBody.push(messageBody || '');
|
||||||
|
if (safeStaffSigText) {
|
||||||
|
plainBody.push('');
|
||||||
|
plainBody.push(safeStaffSigText);
|
||||||
|
}
|
||||||
|
plainBody.push('');
|
||||||
|
plainBody.push(...buildCompanySigText().split('\n'));
|
||||||
|
|
||||||
|
const headers = [
|
||||||
`From: ${sanitizeHeaderValue(CONFIG.MY_EMAIL)}`,
|
`From: ${sanitizeHeaderValue(CONFIG.MY_EMAIL)}`,
|
||||||
`To: ${recipientEmail}`,
|
`To: ${recipientEmail}`,
|
||||||
`Subject: ${utf8Subject}`,
|
`Subject: ${utf8Subject}`,
|
||||||
msgId ? `In-Reply-To: ${msgId}` : '',
|
msgId && `In-Reply-To: ${msgId}`,
|
||||||
msgId ? `References: ${msgId}` : '',
|
msgId && `References: ${msgId}`,
|
||||||
'MIME-Version: 1.0',
|
'MIME-Version: 1.0',
|
||||||
'Content-Type: text/html; charset="UTF-8"',
|
`Content-Type: multipart/alternative; boundary="${boundary}"`
|
||||||
'',
|
|
||||||
htmlBody
|
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
|
||||||
const raw = Buffer.from(rawHeaders.join('\r\n'))
|
const raw = Buffer.from([
|
||||||
|
...headers,
|
||||||
|
'',
|
||||||
|
`--${boundary}`,
|
||||||
|
'Content-Type: text/plain; charset="UTF-8"',
|
||||||
|
'',
|
||||||
|
...plainBody,
|
||||||
|
'',
|
||||||
|
`--${boundary}`,
|
||||||
|
'Content-Type: text/html; charset="UTF-8"',
|
||||||
|
'',
|
||||||
|
htmlBody,
|
||||||
|
'',
|
||||||
|
`--${boundary}--`
|
||||||
|
].join('\r\n'))
|
||||||
.toString('base64')
|
.toString('base64')
|
||||||
.replace(/\+/g, '-')
|
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
||||||
.replace(/\//g, '_')
|
|
||||||
.replace(/=+$/, '');
|
|
||||||
|
|
||||||
await gmail.users.messages.send({
|
await gmail.users.messages.send({
|
||||||
userId: 'me',
|
userId: 'me',
|
||||||
@@ -263,7 +300,6 @@ async function sendGmailReply(
|
|||||||
const utf8Subject = `=?utf-8?B?${Buffer.from(
|
const utf8Subject = `=?utf-8?B?${Buffer.from(
|
||||||
safeSubject
|
safeSubject
|
||||||
).toString('base64')}?=`;
|
).toString('base64')}?=`;
|
||||||
const safeLogoUrl = escapeHtml(CONFIG.LOGO_URL || '');
|
|
||||||
|
|
||||||
let signatureBlocks = { text: '', html: '' };
|
let signatureBlocks = { text: '', html: '' };
|
||||||
if (userId) {
|
if (userId) {
|
||||||
@@ -277,14 +313,7 @@ async function sendGmailReply(
|
|||||||
<div style="font-family: sans-serif; font-size: 14px; color: #333;">
|
<div style="font-family: sans-serif; font-size: 14px; color: #333;">
|
||||||
<p>${escapeHtml(replyText).replace(/\n/g, '<br>')}</p>
|
<p>${escapeHtml(replyText).replace(/\n/g, '<br>')}</p>
|
||||||
${safeStaffSigHtml ? `<p style="margin: 10px 0;">${safeStaffSigHtml}</p>` : ''}
|
${safeStaffSigHtml ? `<p style="margin: 10px 0;">${safeStaffSigHtml}</p>` : ''}
|
||||||
<div>
|
${buildCompanySigHtml()}
|
||||||
${safeLogoUrl ? `<img src="${safeLogoUrl}" width="65" alt="Indifferent Broccoli"><br>` : ''}
|
|
||||||
Indifferent Broccoli Support<br>
|
|
||||||
<a href="https://indifferentbroccoli.com/">https://indifferentbroccoli.com/</a><br>
|
|
||||||
Join us on <a href="https://discord.gg/2vmfrrtvJY">Discord</a><br>
|
|
||||||
<br>
|
|
||||||
<em>"We eat lag for breakfast. Whatever."</em>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
const boundary = '000000000000' + Date.now().toString(16);
|
const boundary = '000000000000' + Date.now().toString(16);
|
||||||
@@ -296,37 +325,35 @@ async function sendGmailReply(
|
|||||||
plainBody.push(safeStaffSigText);
|
plainBody.push(safeStaffSigText);
|
||||||
}
|
}
|
||||||
plainBody.push('');
|
plainBody.push('');
|
||||||
plainBody.push('Indifferent Broccoli Support');
|
plainBody.push(...buildCompanySigText().split('\n'));
|
||||||
plainBody.push('https://indifferentbroccoli.com/');
|
|
||||||
plainBody.push('Join us on Discord: https://discord.gg/2vmfrrtvJY');
|
|
||||||
plainBody.push('');
|
|
||||||
plainBody.push('"We eat lag for breakfast. Whatever."');
|
|
||||||
|
|
||||||
const raw = Buffer.from([
|
const headers = [
|
||||||
`From: ${sanitizeHeaderValue(CONFIG.MY_EMAIL)}`,
|
`From: ${sanitizeHeaderValue(CONFIG.MY_EMAIL)}`,
|
||||||
`To: ${safeRecipient}`,
|
`To: ${safeRecipient}`,
|
||||||
`Subject: ${utf8Subject}`,
|
`Subject: ${utf8Subject}`,
|
||||||
safeMessageId ? `In-Reply-To: ${safeMessageId}` : '',
|
safeMessageId && `In-Reply-To: ${safeMessageId}`,
|
||||||
safeMessageId ? `References: ${safeMessageId}` : '',
|
safeMessageId && `References: ${safeMessageId}`,
|
||||||
'MIME-Version: 1.0',
|
'MIME-Version: 1.0',
|
||||||
'Content-Type: multipart/alternative; boundary="' + boundary + '"',
|
`Content-Type: multipart/alternative; boundary="${boundary}"`
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
const raw = Buffer.from([
|
||||||
|
...headers,
|
||||||
'',
|
'',
|
||||||
'--' + boundary,
|
`--${boundary}`,
|
||||||
'Content-Type: text/plain; charset="UTF-8"',
|
'Content-Type: text/plain; charset="UTF-8"',
|
||||||
'',
|
'',
|
||||||
...plainBody,
|
...plainBody,
|
||||||
'',
|
'',
|
||||||
'--' + boundary,
|
`--${boundary}`,
|
||||||
'Content-Type: text/html; charset="UTF-8"',
|
'Content-Type: text/html; charset="UTF-8"',
|
||||||
'',
|
'',
|
||||||
htmlBody,
|
htmlBody,
|
||||||
'',
|
'',
|
||||||
'--' + boundary + '--'
|
`--${boundary}--`
|
||||||
].join('\r\n'))
|
].join('\r\n'))
|
||||||
.toString('base64')
|
.toString('base64')
|
||||||
.replace(/\+/g, '-')
|
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
||||||
.replace(/\//g, '_')
|
|
||||||
.replace(/=+$/, '');
|
|
||||||
|
|
||||||
await gmail.users.messages.send({
|
await gmail.users.messages.send({
|
||||||
userId: 'me',
|
userId: 'me',
|
||||||
|
|||||||
Reference in New Issue
Block a user