courrier preview

This commit is contained in:
alma 2025-05-01 20:15:34 +02:00
parent 7a4a9f2c14
commit 2900e0d188

View File

@ -326,12 +326,19 @@ export function formatReplyEmail(originalEmail: EmailMessage | LegacyEmailMessag
if (htmlContent) { if (htmlContent) {
// Format HTML reply // Format HTML reply
console.log('Formatting HTML reply, quoted content length:', htmlContent.length); console.log('Formatting HTML reply, quoted content length:', htmlContent.length);
const sanitizedReplyContent = sanitizeHtml(htmlContent);
console.log('Sanitized reply content length:', sanitizedReplyContent.length);
console.log('Sanitized reply content truncated sample:',
sanitizedReplyContent.length > 100
? sanitizedReplyContent.substring(0, 100) + '...'
: sanitizedReplyContent || 'EMPTY');
htmlContent = ` htmlContent = `
<div style="margin: 20px 0 10px 0; color: #666; border-bottom: 1px solid #ddd; padding-bottom: 5px;"> <div style="margin: 20px 0 10px 0; color: #666; border-bottom: 1px solid #ddd; padding-bottom: 5px;">
On ${date}, ${sender} wrote: On ${date}, ${sender} wrote:
</div> </div>
<blockquote style="margin: 0; padding-left: 10px; border-left: 3px solid #ddd; color: #505050; background-color: #f9f9f9; padding: 10px;"> <blockquote style="margin: 0; padding-left: 10px; border-left: 3px solid #ddd; color: #505050; background-color: #f9f9f9; padding: 10px;">
${sanitizeHtml(htmlContent)} ${sanitizedReplyContent}
</blockquote> </blockquote>
`; `;
} }
@ -458,8 +465,12 @@ export function formatForwardedEmail(originalEmail: EmailMessage | LegacyEmailMe
console.log('Formatting HTML forward, original content length:', htmlContent.length); console.log('Formatting HTML forward, original content length:', htmlContent.length);
// Important: First sanitize the content portion only // Important: First sanitize the content portion only
const sanitizedOriginalContent = sanitizeHtml(htmlContent); const sanitizedReplyContent = sanitizeHtml(htmlContent);
console.log('Sanitized original content length:', sanitizedOriginalContent.length); console.log('Sanitized forward content length:', sanitizedReplyContent.length);
console.log('Sanitized forward content truncated sample:',
sanitizedReplyContent.length > 100
? sanitizedReplyContent.substring(0, 100) + '...'
: sanitizedReplyContent || 'EMPTY');
// Create the complete forwarded email with header info // Create the complete forwarded email with header info
const fullForwardedEmail = ` const fullForwardedEmail = `
@ -492,9 +503,9 @@ export function formatForwardedEmail(originalEmail: EmailMessage | LegacyEmailMe
</tbody> </tbody>
</table> </table>
</div> </div>
<div style="margin: 0; padding-left: 10px; border-left: 3px solid #ddd; color: #505050; background-color: #f9f9f9; padding: 10px;"> <blockquote style="margin: 0; padding-left: 10px; border-left: 3px solid #ddd; color: #505050; background-color: #f9f9f9; padding: 10px;">
${sanitizedOriginalContent} ${sanitizedReplyContent}
</div> </blockquote>
`; `;
// Now we have the full forwarded email structure without sanitizing it again // Now we have the full forwarded email structure without sanitizing it again