This commit is contained in:
2025-06-10 20:56:56 +02:00
parent cf4af2cbff
commit 09c32ae6cb
3 changed files with 136 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ interface EmailMessage {
timestamp: string;
direction: 'sent' | 'received';
threadId?: string;
attachments?: any[];
}
export default defineEventHandler(async (event) => {
@@ -304,6 +305,15 @@ async function fetchImapEmails(
return;
}
// Extract attachments
const attachments = parsed.attachments ? parsed.attachments.map((att: any) => ({
filename: att.filename || 'attachment',
name: att.filename || 'attachment',
size: att.size || 0,
type: att.contentType || 'application/octet-stream',
cid: att.cid || undefined
})) : [];
const email: EmailMessage = {
id: parsed.messageId || `${Date.now()}-${seqno}`,
from: fromEmail,
@@ -312,7 +322,8 @@ async function fetchImapEmails(
body: parsed.text || '',
html: parsed.html || undefined,
timestamp: parsed.date?.toISOString() || new Date().toISOString(),
direction: fromEmail.toLowerCase().includes(userEmail.toLowerCase()) ? 'sent' : 'received'
direction: fromEmail.toLowerCase().includes(userEmail.toLowerCase()) ? 'sent' : 'received',
attachments: attachments
};
if (parsed.headers.has('in-reply-to')) {

View File

@@ -181,7 +181,8 @@ export default defineEventHandler(async (event) => {
html: htmlBody,
timestamp: new Date().toISOString(),
direction: 'sent',
interestId: interestId
interestId: interestId,
attachments: attachments // Include attachment info
};
const objectName = `interest-${interestId}/${Date.now()}-sent.json`;