courrier preview

This commit is contained in:
alma 2025-05-01 22:18:45 +02:00
parent 8d6e0c85b2
commit e88ef38222

View File

@ -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
}
}
}