From e88ef382223bcce7eee71fe07a6848dfad4a12b2 Mon Sep 17 00:00:00 2001 From: alma Date: Thu, 1 May 2025 22:18:45 +0200 Subject: [PATCH] courrier preview --- app/api/courrier/delete/route.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/api/courrier/delete/route.ts b/app/api/courrier/delete/route.ts index 1b0e618a..34b018cb 100644 --- a/app/api/courrier/delete/route.ts +++ b/app/api/courrier/delete/route.ts @@ -87,7 +87,21 @@ export async function POST(request: Request) { // Move messages to trash for (const emailId of emailIds) { - await client.messageMove(emailId, trashFolder); + try { + // Convert the emailId to a number if it's a string + const uid = typeof emailId === 'string' ? parseInt(emailId, 10) : emailId; + + // Debug logging for troubleshooting + console.log(`[DELETE API] Moving email with UID ${uid} to trash folder "${trashFolder}"`); + + // Use the correct syntax for messageMove method + await client.messageMove(uid.toString(), trashFolder, { uid: true }); + + console.log(`[DELETE API] Successfully moved email ${uid} to trash`); + } catch (moveError) { + console.error(`[DELETE API] Error moving email ${emailId} to trash:`, moveError); + // Continue with other emails even if one fails + } } }