courrier multi account restore compose
This commit is contained in:
parent
2f76050352
commit
d6728947c6
@ -279,7 +279,7 @@ export async function getEmails(
|
|||||||
? `email:list:${userId}:${accountId}:${folder}:${page}:${perPage}:${searchQuery}`
|
? `email:list:${userId}:${accountId}:${folder}:${page}:${perPage}:${searchQuery}`
|
||||||
: `email:list:${userId}:${folder}:${page}:${perPage}:${searchQuery}`;
|
: `email:list:${userId}:${folder}:${page}:${perPage}:${searchQuery}`;
|
||||||
|
|
||||||
const cached = await getCachedEmailList(cacheKey);
|
const cached = await getCachedEmailList(userId, accountId || 'default', folder, page, perPage);
|
||||||
if (cached) {
|
if (cached) {
|
||||||
console.log(`Using cached email list for ${cacheKey}`);
|
console.log(`Using cached email list for ${cacheKey}`);
|
||||||
return cached;
|
return cached;
|
||||||
@ -339,7 +339,9 @@ export async function getEmails(
|
|||||||
deleted: message.flags.has('\\Deleted')
|
deleted: message.flags.has('\\Deleted')
|
||||||
},
|
},
|
||||||
size: message.size || 0,
|
size: message.size || 0,
|
||||||
hasAttachments: message.bodyStructure?.childNodes?.some(node => node.disposition === 'attachment') || false
|
hasAttachments: message.bodyStructure?.childNodes?.some(node => node.disposition === 'attachment') || false,
|
||||||
|
folder: folder,
|
||||||
|
contentFetched: false
|
||||||
};
|
};
|
||||||
emails.push(email);
|
emails.push(email);
|
||||||
}
|
}
|
||||||
@ -355,7 +357,7 @@ export async function getEmails(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Cache the result
|
// Cache the result
|
||||||
await cacheEmailList(cacheKey, result);
|
await cacheEmailList(userId, accountId || 'default', folder, page, perPage, result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -391,14 +393,15 @@ export async function getEmailContent(
|
|||||||
const message = await client.fetchOne(emailId, {
|
const message = await client.fetchOne(emailId, {
|
||||||
source: true,
|
source: true,
|
||||||
envelope: true,
|
envelope: true,
|
||||||
flags: true
|
flags: true,
|
||||||
|
size: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!message) {
|
if (!message) {
|
||||||
throw new Error('Email not found');
|
throw new Error('Email not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { source, envelope, flags } = message;
|
const { source, envelope, flags, size } = message;
|
||||||
|
|
||||||
// Parse the email content, ensuring all styles and structure are preserved
|
// Parse the email content, ensuring all styles and structure are preserved
|
||||||
const parsedEmail = await simpleParser(source.toString(), {
|
const parsedEmail = await simpleParser(source.toString(), {
|
||||||
@ -412,7 +415,7 @@ export async function getEmailContent(
|
|||||||
// Preserve the raw HTML exactly as it was in the original email
|
// Preserve the raw HTML exactly as it was in the original email
|
||||||
const rawHtml = parsedEmail.html || '';
|
const rawHtml = parsedEmail.html || '';
|
||||||
|
|
||||||
const email = {
|
const email: EmailMessage = {
|
||||||
id: emailId,
|
id: emailId,
|
||||||
messageId: envelope.messageId,
|
messageId: envelope.messageId,
|
||||||
subject: envelope.subject || "(No Subject)",
|
subject: envelope.subject || "(No Subject)",
|
||||||
@ -446,13 +449,12 @@ export async function getEmailContent(
|
|||||||
contentType: att.contentType,
|
contentType: att.contentType,
|
||||||
size: att.size || 0
|
size: att.size || 0
|
||||||
})),
|
})),
|
||||||
// Preserve the exact raw HTML to maintain all styling
|
|
||||||
html: rawHtml,
|
html: rawHtml,
|
||||||
text: parsedEmail.text || undefined,
|
text: parsedEmail.text || undefined,
|
||||||
// For content field, prioritize using the raw HTML to preserve all styling
|
|
||||||
content: rawHtml || parsedEmail.text || '',
|
content: rawHtml || parsedEmail.text || '',
|
||||||
folder,
|
folder,
|
||||||
contentFetched: true
|
contentFetched: true,
|
||||||
|
size: size || 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cache the email content
|
// Cache the email content
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user