diff --git a/.env b/.env
index 36f3843e..9cc6b291 100644
--- a/.env
+++ b/.env
@@ -77,6 +77,12 @@ IMAP_HOST=mail.infomaniak.com
IMAP_PORT=993
NEWS_API_URL="http://172.16.0.104:8000"
+
+
+# Required Redis environment variables to add to .env
+REDIS_URL=redis://:mySecretPassword@localhost:6379
+REDIS_PASSWORD=mySecretPassword
REDIS_HOST=localhost
REDIS_PORT=6379
-REDIS_PASSWORD=mySecretPassword
+# Add a secret key for encrypting sensitive data in Redis
+REDIS_ENCRYPTION_KEY=your-random-32-char-encryption-key
\ No newline at end of file
diff --git a/app/api/courrier/account-folders/route.ts b/app/api/courrier/account-folders/route.ts
index efbc8695..622d8cfa 100644
--- a/app/api/courrier/account-folders/route.ts
+++ b/app/api/courrier/account-folders/route.ts
@@ -105,28 +105,28 @@ export async function GET(request: Request) {
const accountsWithFolders = await Promise.all(accounts.map(async (account) => {
try {
// Connect to IMAP server for this specific account
- const client = new ImapFlow({
+ const client = new ImapFlow({
host: account.host,
port: account.port,
- secure: true,
- auth: {
+ secure: true,
+ auth: {
user: account.email,
pass: account.password,
- },
- logger: false,
- tls: {
- rejectUnauthorized: false
- }
- });
-
- await client.connect();
-
+ },
+ logger: false,
+ tls: {
+ rejectUnauthorized: false
+ }
+ });
+
+ await client.connect();
+
// Get folders for this account
- const folders = await getMailboxes(client);
-
- // Close connection
- await client.logout();
-
+ const folders = await getMailboxes(client);
+
+ // Close connection
+ await client.logout();
+
// Add display_name and color from database
const metadata = await prisma.$queryRaw`
SELECT display_name, color
@@ -143,7 +143,7 @@ export async function GET(request: Request) {
color: displayMetadata.color || "#0082c9",
folders
};
- } catch (error) {
+ } catch (error) {
console.error(`Error fetching folders for account ${account.email}:`, error);
// Return fallback folders on error
return {
diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx
index 0efb79a0..0f7df298 100644
--- a/app/courrier/page.tsx
+++ b/app/courrier/page.tsx
@@ -11,7 +11,7 @@ import {
MoreHorizontal, FolderOpen, X, Paperclip, MessageSquare, Copy, EyeOff,
AlertOctagon, Archive, RefreshCw, Menu
} from 'lucide-react';
-import { Dialog, DialogContent } from '@/components/ui/dialog';
+import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import {
AlertDialog,
@@ -143,13 +143,13 @@ export default function CourrierPage() {
const updated = [...prev];
if (updated.length > 1) {
// Only update folders, preserve other properties including ID
- if (updated[1]) {
+ if (updated[1]) {
updated[1] = {
...updated[1],
folders: mailboxes
};
- }
- console.log('Updated accounts with new mailboxes:', updated);
+ }
+ console.log('Updated accounts with new mailboxes:', updated);
}
return updated;
});
@@ -265,7 +265,7 @@ export default function CourrierPage() {
});
});
}
-
+
if (!isMounted) return;
if (data.authenticated) {
@@ -309,11 +309,11 @@ export default function CourrierPage() {
// Update the loading account in place to maintain references
updatedAccounts[1] = {
id: account.id, // Use the real account ID
- name: account.display_name || account.email,
- email: account.email,
- color: account.color || 'bg-blue-500',
+ name: account.display_name || account.email,
+ email: account.email,
+ color: account.color || 'bg-blue-500',
folders: accountFolders
- };
+ };
console.log(`[DEBUG] Updated loading account to real account: ${account.email} with ID ${account.id}`);
} else {
// Add additional accounts as new entries
@@ -346,16 +346,16 @@ export default function CourrierPage() {
});
}
} else if (data.email) {
- // Fallback to single account if allAccounts is not available
- console.log(`[DEBUG] Fallback to single account: ${data.email}`);
-
- // Force include some hardcoded folders if none are present
- const fallbackFolders = ['INBOX', 'Sent', 'Drafts', 'Trash', 'Junk'];
-
- // Prioritize mailboxes from IMAP if available
- const folderList = (data.mailboxes && data.mailboxes.length > 0) ?
- data.mailboxes : fallbackFolders;
-
+ // Fallback to single account if allAccounts is not available
+ console.log(`[DEBUG] Fallback to single account: ${data.email}`);
+
+ // Force include some hardcoded folders if none are present
+ const fallbackFolders = ['INBOX', 'Sent', 'Drafts', 'Trash', 'Junk'];
+
+ // Prioritize mailboxes from IMAP if available
+ const folderList = (data.mailboxes && data.mailboxes.length > 0) ?
+ data.mailboxes : fallbackFolders;
+
// Update the loading account if it exists
if (updatedAccounts.length > 1) {
updatedAccounts[1] = {
@@ -677,195 +677,195 @@ export default function CourrierPage() {