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