courrier clean 2

This commit is contained in:
alma 2025-04-26 14:28:56 +02:00
parent 6f38d53335
commit f4112f3160

View File

@ -631,20 +631,20 @@ export async function testEmailConnection(credentials: EmailCredentials): Promis
/** /**
* Format email for reply/forward * Format email for reply/forward
*/ */
export function formatEmailForReplyOrForward( export async function formatEmailForReplyOrForward(
email: EmailMessage, email: EmailMessage,
type: 'reply' | 'reply-all' | 'forward' type: 'reply' | 'reply-all' | 'forward'
): { ): Promise<{
to: string; to: string;
cc?: string; cc?: string;
subject: string; subject: string;
body: string; body: string;
} { }> {
// Format the subject with Re: or Fwd: prefix // Format the subject with Re: or Fwd: prefix
const subject = formatSubject(email.subject, type); const subject = await formatSubject(email.subject, type);
// Create the email quote with proper formatting // Create the email quote with proper formatting
const quoteHeader = createQuoteHeader(email); const quoteHeader = await createQuoteHeader(email);
const quotedContent = email.html || email.text || ''; const quotedContent = email.html || email.text || '';
// Format recipients // Format recipients
@ -720,7 +720,7 @@ export function formatEmailForReplyOrForward(
/** /**
* Format subject with appropriate prefix (Re:, Fwd:) * Format subject with appropriate prefix (Re:, Fwd:)
*/ */
function formatSubject(subject: string, type: 'reply' | 'reply-all' | 'forward'): string { async function formatSubject(subject: string, type: 'reply' | 'reply-all' | 'forward'): Promise<string> {
// Clean up any existing prefixes // Clean up any existing prefixes
let cleanSubject = subject let cleanSubject = subject
.replace(/^(Re|Fwd|FW|Forward):\s*/i, '') .replace(/^(Re|Fwd|FW|Forward):\s*/i, '')
@ -743,7 +743,7 @@ function formatSubject(subject: string, type: 'reply' | 'reply-all' | 'forward')
/** /**
* Create a quote header for reply/forward * Create a quote header for reply/forward
*/ */
function createQuoteHeader(email: EmailMessage): string { async function createQuoteHeader(email: EmailMessage): Promise<string> {
// Format the date // Format the date
const date = new Date(email.date); const date = new Date(email.date);
const formattedDate = date.toLocaleString('en-US', { const formattedDate = date.toLocaleString('en-US', {