courrier clean 2
This commit is contained in:
parent
6f38d53335
commit
f4112f3160
@ -631,20 +631,20 @@ export async function testEmailConnection(credentials: EmailCredentials): Promis
|
||||
/**
|
||||
* Format email for reply/forward
|
||||
*/
|
||||
export function formatEmailForReplyOrForward(
|
||||
export async function formatEmailForReplyOrForward(
|
||||
email: EmailMessage,
|
||||
type: 'reply' | 'reply-all' | 'forward'
|
||||
): {
|
||||
): Promise<{
|
||||
to: string;
|
||||
cc?: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
} {
|
||||
}> {
|
||||
// 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
|
||||
const quoteHeader = createQuoteHeader(email);
|
||||
const quoteHeader = await createQuoteHeader(email);
|
||||
const quotedContent = email.html || email.text || '';
|
||||
|
||||
// Format recipients
|
||||
@ -720,7 +720,7 @@ export function formatEmailForReplyOrForward(
|
||||
/**
|
||||
* 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
|
||||
let cleanSubject = subject
|
||||
.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
|
||||
*/
|
||||
function createQuoteHeader(email: EmailMessage): string {
|
||||
async function createQuoteHeader(email: EmailMessage): Promise<string> {
|
||||
// Format the date
|
||||
const date = new Date(email.date);
|
||||
const formattedDate = date.toLocaleString('en-US', {
|
||||
@ -762,4 +762,4 @@ function createQuoteHeader(email: EmailMessage): string {
|
||||
: sender?.address || 'Unknown sender';
|
||||
|
||||
return `<div style="font-weight: 500;">On ${formattedDate}, ${fromText} wrote:</div>`;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user