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;
|
||||
starred: boolean;
|
||||
body: string;
|
||||
to?: string;
|
||||
}
|
||||
|
||||
interface ImapBox {
|
||||
@ -180,13 +181,18 @@ export async function GET() {
|
||||
};
|
||||
|
||||
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 processedMsg = await processMessage(msg);
|
||||
messages.push(processedMsg);
|
||||
}
|
||||
imap.end();
|
||||
|
||||
console.log('Raw messages:', messages);
|
||||
|
||||
const emails: Email[] = messages.map((msg) => {
|
||||
return {
|
||||
id: msg.uid.toString(),
|
||||
@ -195,7 +201,8 @@ export async function GET() {
|
||||
date: msg.date,
|
||||
read: !msg.flags?.includes('\\Unseen'),
|
||||
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
|
||||
];
|
||||
|
||||
// Filter emails based on selected account and current view
|
||||
const filteredEmails = emails.filter(email => {
|
||||
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;
|
||||
}
|
||||
});
|
||||
// TEMP: Show all emails for debugging
|
||||
const filteredEmails = emails;
|
||||
|
||||
// Format date for display
|
||||
const formatDate = (dateString: string) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user