This commit is contained in:
indifferentketchup
2026-04-10 08:57:55 -05:00
parent eae801ff7d
commit a1cd67fd73
2 changed files with 13 additions and 20 deletions

View File

@@ -16,8 +16,6 @@ const {
stripEmailQuotes,
stripMobileFooter,
detectGame,
getFormattedDate,
truncateEmbedField,
enforceEmbedLimit
} = require('./utils');
const { getGmailClient } = require('./services/gmail');
@@ -107,9 +105,11 @@ async function poll(client) {
?.replace(/"/g, '')
.trim() || 'Unknown';
const hasReplyHeaderFrom =
/(?:\n{2,}|(?:^|\n)--\s*\n)[^\S\r\n]*From:\s.*<.*@.*>/i.test(rawBody);
const looksLikeReply =
/\nOn .+wrote:/i.test(rawBody) ||
/\nFrom:\s.*<.*@.*>/i.test(rawBody);
hasReplyHeaderFrom;
let firstBodyText = rawBody.replace(/\r\n/g, '\n');
if (looksLikeReply) {
@@ -120,7 +120,6 @@ async function poll(client) {
firstBodyText = firstBodyText.replace(/\n{3,}/g, '\n\n');
firstBodyText = firstBodyText
.replace(/Get Outlook for [^\n]+/gi, '')
.replace(/https?:\/\/\S+/gi, '')
.replace(/<\s*$/gm, '')
.trim();
const firstBody = firstBodyText;
@@ -135,7 +134,6 @@ async function poll(client) {
followupBody = stripMobileFooter(followupBody);
followupBody = followupBody
.replace(/Get Outlook for [^\n]+/gi, '')
.replace(/https?:\/\/\S+/gi, '')
.replace(/<\s*$/gm, '')
.trim();
@@ -239,25 +237,19 @@ async function poll(client) {
.setStyle(ButtonStyle.Secondary)
);
const welcomeEmbed = new EmbedBuilder()
.setDescription(CONFIG.TICKET_WELCOME_MESSAGE)
.setColor(CONFIG.EMBED_COLOR_INFO);
const ticketInfoEmbed = new EmbedBuilder()
.setColor(CONFIG.EMBED_COLOR_INFO)
.addFields({
name: 'Ticket Info',
value: truncateEmbedField(
`**Name:** ${sName}\n` +
`**Email:** ${sEmail}\n` +
`**Date:** ${getFormattedDate()}\n` +
`**Game:** ${detectedGame}\n` +
`**Subject:** ${subject || 'No subject'}`)
});
.addFields(
{ name: 'Name', value: `\`${sName}\``, inline: false },
{ name: 'Email', value: `\`${sEmail}\``, inline: false },
{ name: 'Game', value: `\`${detectedGame}\``, inline: false },
{ name: 'Subject', value: `\`${subject || 'No subject'}\``, inline: false }
);
enforceEmbedLimit([welcomeEmbed, ticketInfoEmbed]);
enforceEmbedLimit([ticketInfoEmbed]);
const welcomeMsg = await ticketChan.send({
content: `<@&${CONFIG.ROLE_ID_TO_PING}>`,
embeds: [welcomeEmbed, ticketInfoEmbed],
embeds: [ticketInfoEmbed],
components: [buttons]
});

View File

@@ -19,7 +19,8 @@ app.use(session({
saveUninitialized: false,
cookie: {
httpOnly: true,
secure: false, // set true if behind HTTPS proxy
secure: true,
sameSite: 'lax',
maxAge: 8 * 60 * 60 * 1000 // 8 hours
}
}));