courrier multi account restore compose

This commit is contained in:
alma 2025-04-28 15:09:35 +02:00
parent 7e18722d3c
commit e2805dca07

View File

@ -275,10 +275,12 @@ export async function getEmails(
console.log(`Fetching emails for user ${userId}${accountId ? ` account ${accountId}` : ''} in folder ${folder}`);
// Extract the base folder name if it's an account-specific folder
const baseFolder = accountId && folder.endsWith(`-${accountId}`)
? folder.slice(0, -accountId.length - 1)
const baseFolder = accountId && folder.includes(`-${accountId}`)
? folder.split(`-${accountId}`)[0]
: folder;
console.log(`Using base folder name: ${baseFolder} for IMAP operations`);
// Try to get from cache first
const cached = await getCachedEmailList(userId, accountId || 'default', folder, page, perPage);
if (cached) {
@ -362,8 +364,10 @@ export async function getEmails(
// Cache the result with the account-specific folder
await cacheEmailList(userId, accountId || 'default', folder, page, perPage, result);
// No need to invalidate other accounts' caches since folders are now account-specific
return result;
} catch (error) {
console.error(`Error fetching emails for folder ${baseFolder}:`, error);
throw error;
} finally {
try {
await client.mailboxClose();