From 814d63f43460d044b8ec00cc79627a7549ec91a0 Mon Sep 17 00:00:00 2001 From: alma Date: Mon, 28 Apr 2025 15:19:31 +0200 Subject: [PATCH] courrier multi account restore compose --- lib/services/email-service.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/services/email-service.ts b/lib/services/email-service.ts index 2cb14274..97a27aa8 100644 --- a/lib/services/email-service.ts +++ b/lib/services/email-service.ts @@ -270,7 +270,7 @@ export async function getEmails( page: number = 1, perPage: number = 20, accountId?: string -): Promise { +): Promise { try { // Extract the base folder name by removing the accountId suffix if present const baseFolder = accountId && folder.includes(`-${accountId}`) @@ -340,7 +340,18 @@ export async function getEmails( await cacheEmailList(userId, accountId, folder, page, perPage, emails); } - return emails; + // Get mailboxes for this account + const mailboxes = await getMailboxes(imap, accountId); + + return { + emails, + totalEmails: total, + page, + perPage, + totalPages: Math.ceil(total / perPage), + folder, + mailboxes + }; } catch (error) { console.error(`Error fetching emails for folder ${folder}:`, error); throw error;