courrier clean 2$

This commit is contained in:
alma 2025-04-26 19:37:32 +02:00
parent afc7f64027
commit 1663721c89
2 changed files with 1330 additions and 62 deletions

File diff suppressed because it is too large Load Diff

View File

@ -136,6 +136,34 @@ export function formatForwardedEmail(email: EmailMessage): {
// Get and clean original content
const originalContent = cleanHtmlContent(email.content || email.html || email.text || '');
// Check if the content already has a forwarded message header
// Look for common forwarded message header patterns
const forwardedPatterns = [
'---------- Forwarded message ---------',
'Forwarded message',
'-------- Original Message --------',
'Begin forwarded message',
'From:.*Date:.*Subject:.*To:', // Common pattern in forwarded emails
'From:.*Sent:.*To:.*Subject:', // Microsoft Outlook pattern
];
// Use a regular expression to check for all patterns, with case insensitivity
const hasExistingHeader = forwardedPatterns.some(pattern =>
new RegExp(pattern, 'i').test(originalContent)
);
// If there's already a forwarded message header, don't add another one
if (hasExistingHeader) {
// Just wrap the content in appropriate styling without adding another header
const content = `
<div style="min-height: 20px;"></div>
<div style="direction: ltr; text-align: left;" dir="ltr" class="email-original-content">
${originalContent}
</div>
`;
return { subject, content };
}
// Create formatted content with explicit LTR formatting
const content = `
<div style="min-height: 20px;"></div>