mail page imap connection mime 5 bis rest 16 login page 21
This commit is contained in:
parent
c025203267
commit
37fad90280
@ -19,6 +19,7 @@ interface Email {
|
|||||||
read: boolean;
|
read: boolean;
|
||||||
starred: boolean;
|
starred: boolean;
|
||||||
body: string;
|
body: string;
|
||||||
|
to?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImapBox {
|
interface ImapBox {
|
||||||
@ -180,13 +181,18 @@ export async function GET() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const messages: any[] = [];
|
const messages: any[] = [];
|
||||||
for (let seqno = 1; seqno <= 10; seqno++) {
|
// Fetch the most recent 20 emails
|
||||||
|
const start = Math.max(1, box.messages.total - 19); // last 20 emails
|
||||||
|
const end = box.messages.total;
|
||||||
|
for (let seqno = start; seqno <= end; seqno++) {
|
||||||
const msg = await fetchPromise(imap, seqno);
|
const msg = await fetchPromise(imap, seqno);
|
||||||
const processedMsg = await processMessage(msg);
|
const processedMsg = await processMessage(msg);
|
||||||
messages.push(processedMsg);
|
messages.push(processedMsg);
|
||||||
}
|
}
|
||||||
imap.end();
|
imap.end();
|
||||||
|
|
||||||
|
console.log('Raw messages:', messages);
|
||||||
|
|
||||||
const emails: Email[] = messages.map((msg) => {
|
const emails: Email[] = messages.map((msg) => {
|
||||||
return {
|
return {
|
||||||
id: msg.uid.toString(),
|
id: msg.uid.toString(),
|
||||||
@ -195,7 +201,8 @@ export async function GET() {
|
|||||||
date: msg.date,
|
date: msg.date,
|
||||||
read: !msg.flags?.includes('\\Unseen'),
|
read: !msg.flags?.includes('\\Unseen'),
|
||||||
starred: msg.flags?.includes('\\Flagged') || false,
|
starred: msg.flags?.includes('\\Flagged') || false,
|
||||||
body: msg.body
|
body: msg.body,
|
||||||
|
to: msg.to // add this if available
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -484,26 +484,8 @@ export default function MailPage() {
|
|||||||
...accounts
|
...accounts
|
||||||
];
|
];
|
||||||
|
|
||||||
// Filter emails based on selected account and current view
|
// TEMP: Show all emails for debugging
|
||||||
const filteredEmails = emails.filter(email => {
|
const filteredEmails = emails;
|
||||||
if (selectedAccount) {
|
|
||||||
return email.to === selectedAccount.email;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}).filter(email => {
|
|
||||||
switch (currentView) {
|
|
||||||
case 'inbox':
|
|
||||||
return true;
|
|
||||||
case 'starred':
|
|
||||||
return email.starred;
|
|
||||||
case 'sent':
|
|
||||||
return email.category === 'sent';
|
|
||||||
case 'trash':
|
|
||||||
return email.category === 'trash';
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Format date for display
|
// Format date for display
|
||||||
const formatDate = (dateString: string) => {
|
const formatDate = (dateString: string) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user