log: remove detailed logging of full SES notification for inbound email
This commit is contained in:
@@ -109,7 +109,6 @@ export class Webhooks {
|
|||||||
// Check if this is an inbound email notification (SES Receiving)
|
// Check if this is an inbound email notification (SES Receiving)
|
||||||
if (body.notificationType === 'Received') {
|
if (body.notificationType === 'Received') {
|
||||||
signale.info('[WEBHOOK] Received inbound email notification from SES');
|
signale.info('[WEBHOOK] Received inbound email notification from SES');
|
||||||
signale.info('[WEBHOOK] Full SES notification:', JSON.stringify(body, null, 2));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Extract recipient addresses from the inbound email
|
// Extract recipient addresses from the inbound email
|
||||||
@@ -160,15 +159,10 @@ export class Webhooks {
|
|||||||
|
|
||||||
if (body.content) {
|
if (body.content) {
|
||||||
try {
|
try {
|
||||||
// SES may base64-encode the raw email in the SNS notification.
|
const isBase64 = body.receipt?.action?.encoding === 'BASE64';
|
||||||
// Detect this by checking whether a base64 decode yields valid MIME headers.
|
const emailBuffer = isBase64
|
||||||
const raw = body.content as string;
|
? Buffer.from(body.content as string, 'base64')
|
||||||
const decoded = Buffer.from(raw, 'base64').toString('utf-8');
|
: Buffer.from(body.content as string);
|
||||||
const looksLikeMime =
|
|
||||||
decoded.includes('Content-Type:') ||
|
|
||||||
decoded.includes('MIME-Version:') ||
|
|
||||||
decoded.includes('Received:');
|
|
||||||
const emailBuffer = looksLikeMime ? Buffer.from(raw, 'base64') : Buffer.from(raw);
|
|
||||||
|
|
||||||
const parsed = await simpleParser(emailBuffer);
|
const parsed = await simpleParser(emailBuffer);
|
||||||
htmlBody =
|
htmlBody =
|
||||||
@@ -176,9 +170,6 @@ export class Webhooks {
|
|||||||
parsed.textAsHtml ??
|
parsed.textAsHtml ??
|
||||||
parsed.text ??
|
parsed.text ??
|
||||||
undefined;
|
undefined;
|
||||||
signale.info(
|
|
||||||
`[WEBHOOK] Email content parsed — base64: ${looksLikeMime}, html: ${!!parsed.html}, text: ${!!parsed.text}, result length: ${htmlBody?.length ?? 0}`,
|
|
||||||
);
|
|
||||||
} catch (parseError) {
|
} catch (parseError) {
|
||||||
signale.error('[WEBHOOK] Failed to parse email content:', parseError);
|
signale.error('[WEBHOOK] Failed to parse email content:', parseError);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user