refactor: remove webmail interface, focus on core mail storage functionality
- Remove obsolete CouchDB design documents (webmail.json, dashboard.json) - Clean up webmail-related code from couch/couch.go (WebmailViews, CreateWebmailViews, etc.) - Update documentation to focus on core mail-to-CouchDB storage functionality - Add Future Plans section describing planned webmail viewer as separate component - Apply go fmt formatting and ensure code quality standards - Update test documentation to show raw CouchDB API access patterns - Remove compiled binary from repository This refactor simplifies the codebase to focus on its core purpose: efficiently backing up emails from IMAP to CouchDB. The webmail interface will be developed as a separate, optional component to maintain clean separation of concerns. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c2ad55eaaf
commit
e280aa0aaa
12 changed files with 147 additions and 49 deletions
|
|
@ -22,20 +22,20 @@ type Client struct {
|
|||
|
||||
// MailDocument represents an email message stored in CouchDB
|
||||
type MailDocument struct {
|
||||
ID string `json:"_id,omitempty"`
|
||||
Rev string `json:"_rev,omitempty"`
|
||||
Attachments map[string]AttachmentStub `json:"_attachments,omitempty"` // CouchDB attachments
|
||||
SourceUID string `json:"sourceUid"` // Unique ID from the mail source (e.g., IMAP UID)
|
||||
Mailbox string `json:"mailbox"` // Source mailbox name
|
||||
From []string `json:"from"`
|
||||
To []string `json:"to"`
|
||||
Subject string `json:"subject"`
|
||||
Date time.Time `json:"date"`
|
||||
Body string `json:"body"`
|
||||
Headers map[string][]string `json:"headers"`
|
||||
StoredAt time.Time `json:"storedAt"` // When the document was stored
|
||||
DocType string `json:"docType"` // Always "mail"
|
||||
HasAttachments bool `json:"hasAttachments"` // Indicates if message has attachments
|
||||
ID string `json:"_id,omitempty"`
|
||||
Rev string `json:"_rev,omitempty"`
|
||||
Attachments map[string]AttachmentStub `json:"_attachments,omitempty"` // CouchDB attachments
|
||||
SourceUID string `json:"sourceUid"` // Unique ID from the mail source (e.g., IMAP UID)
|
||||
Mailbox string `json:"mailbox"` // Source mailbox name
|
||||
From []string `json:"from"`
|
||||
To []string `json:"to"`
|
||||
Subject string `json:"subject"`
|
||||
Date time.Time `json:"date"`
|
||||
Body string `json:"body"`
|
||||
Headers map[string][]string `json:"headers"`
|
||||
StoredAt time.Time `json:"storedAt"` // When the document was stored
|
||||
DocType string `json:"docType"` // Always "mail"
|
||||
HasAttachments bool `json:"hasAttachments"` // Indicates if message has attachments
|
||||
}
|
||||
|
||||
// AttachmentStub represents metadata for a CouchDB attachment
|
||||
|
|
@ -94,19 +94,19 @@ func GenerateAccountDBName(accountName, userEmail string) string {
|
|||
if name == "" {
|
||||
name = userEmail
|
||||
}
|
||||
|
||||
|
||||
// Convert to lowercase and replace invalid characters with underscores
|
||||
name = strings.ToLower(name)
|
||||
// CouchDB database names must match: ^[a-z][a-z0-9_$()+/-]*$
|
||||
validName := regexp.MustCompile(`[^a-z0-9_$()+/-]`).ReplaceAllString(name, "_")
|
||||
|
||||
|
||||
// Ensure it starts with a letter and add m2c prefix
|
||||
if len(validName) > 0 && (validName[0] < 'a' || validName[0] > 'z') {
|
||||
validName = "m2c_mail_" + validName
|
||||
} else {
|
||||
validName = "m2c_" + validName
|
||||
}
|
||||
|
||||
|
||||
return validName
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ func (c *Client) GetAllMailDocumentIDs(ctx context.Context, dbName, mailbox stri
|
|||
|
||||
// Create a view query to get all document IDs for the specified mailbox
|
||||
rows := db.AllDocs(ctx)
|
||||
|
||||
|
||||
docIDs := make(map[string]bool)
|
||||
for rows.Next() {
|
||||
docID, err := rows.ID()
|
||||
|
|
@ -240,11 +240,11 @@ func (c *Client) GetAllMailDocumentIDs(ctx context.Context, dbName, mailbox stri
|
|||
docIDs[docID] = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if rows.Err() != nil {
|
||||
return nil, rows.Err()
|
||||
}
|
||||
|
||||
|
||||
return docIDs, nil
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ func (c *Client) SyncMailbox(ctx context.Context, dbName, mailbox string, curren
|
|||
if len(parts) < 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
uidStr := parts[len(parts)-1]
|
||||
uid := uint32(0)
|
||||
if _, err := fmt.Sscanf(uidStr, "%d", &uid); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue