feat: implement per-account databases and native CouchDB attachments

- Create separate CouchDB database for each mail source (account)
- Store email attachments as native CouchDB attachments
- Add GenerateAccountDBName() for CouchDB-compatible database naming
- Update MailDocument structure to support _attachments field
- Implement StoreAttachment() for CouchDB attachment API
- Add placeholder attachment testing for every 3rd message

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2025-08-01 16:12:17 +02:00
commit 79f19a8877
3 changed files with 161 additions and 53 deletions

View file

@ -16,13 +16,21 @@ type ImapClient struct {
// Message represents an email message retrieved from IMAP
type Message struct {
UID uint32
From []string
To []string
Subject string
Date time.Time
Body string
Headers map[string][]string
UID uint32
From []string
To []string
Subject string
Date time.Time
Body string
Headers map[string][]string
Attachments []Attachment
}
// Attachment represents an email attachment
type Attachment struct {
Filename string
ContentType string
Content []byte
}
// NewImapClient creates a new IMAP client from the configuration
@ -87,6 +95,18 @@ func (c *ImapClient) GetMessages(mailbox string, since *time.Time) ([]*Message,
Body: fmt.Sprintf("This is a placeholder message %d from mailbox %s", i, mailbox),
Headers: make(map[string][]string),
}
// Add a sample attachment for testing (every 3rd message)
if i%3 == 0 {
msg.Attachments = []Attachment{
{
Filename: fmt.Sprintf("sample_%d.txt", i),
ContentType: "text/plain",
Content: []byte(fmt.Sprintf("Sample attachment content for message %d", i)),
},
}
}
messages = append(messages, msg)
}