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