Skip to content

Conversation

@dagelf
Copy link

@dagelf dagelf commented Dec 6, 2025

Implements complete mbox file import functionality with dual storage strategy, comprehensive test suite, and REST API endpoints.

Features Added

Core Implementation

  • Mbox file parsing using mbox-reader crate (v0.2.0)
  • Dual storage: mbox files for mbox imports, individual .eml files for IMAP
  • Database entity (MboxFile) with unique model ID 9
  • Full email processing: plain text, HTML, attachments, nested EML

REST API Endpoints

  • POST /import/mbox/:account_id - Import mbox file
  • GET /import/mbox/:account_id - List mbox files
  • DELETE /import/mbox/:id - Delete mbox file record

Indexing & Search

  • Query helper methods for testing
  • Full-text search across all email content
  • Nested EML content extraction and indexing
  • Attachment metadata indexing

Test Infrastructure

  • Test mode configuration (#[cfg(not(test))] guards)
  • Test-specific settings with auto-directory creation
  • Mock mbox generator with 7 email types
  • Comprehensive test suite with 13+ scenarios
  • Tests for plain text, HTML, attachments, nested EML

Technical Details

Files Added

  • src/modules/import/mbox.rs - Core import logic
  • src/modules/mbox/migration.rs - Database entity (model ID: 9)
  • src/modules/mbox/mod.rs - Module definition
  • src/modules/import/mbox_mock.rs - Test data generator
  • src/modules/import/mbox_comprehensive_test.rs - Integration tests
  • src/modules/import/mbox_tests.rs - Simple tests
  • CLAUDE.md - Comprehensive status documentation

Files Modified

  • Cargo.toml - Added mbox-reader dependency
  • src/main.rs - Test mode guard
  • src/modules/settings/cli.rs - Test configuration
  • src/modules/database/mod.rs - Model registration
  • src/modules/indexer/manager.rs - Query helpers + dual storage
  • src/modules/rest/api/import.rs - REST endpoints
  • src/modules/error/code.rs - Added IoError variant
  • Multiple other files for integration

Database Schema

  • MboxFile entity with unique secondary keys (id, path)
  • EML index tracks: mbox_id, mbox_offset, mbox_len
  • mbox_id=0 marker for IMAP emails

Test Coverage

  • 7 distinct email types in mock data
  • Unique searchable keywords per type
  • Tests for content extraction at 3 nesting levels
  • Attachment type validation (PDF, PNG, TXT, CSV, EML)

Fixes Applied

  • Fixed model ID conflict (MboxFile: 5→9, OAuth2 kept 5)
  • Added test mode guards to prevent CLI arg parsing
  • Auto-create test directories in test settings
  • Registered MboxFile in database models

🤖 Generated with Claude Code

Implements complete mbox file import functionality with dual storage strategy,
comprehensive test suite, and REST API endpoints.

## Features Added

### Core Implementation
- Mbox file parsing using mbox-reader crate (v0.2.0)
- Dual storage: mbox files for mbox imports, individual .eml files for IMAP
- Database entity (MboxFile) with unique model ID 9
- Full email processing: plain text, HTML, attachments, nested EML

### REST API Endpoints
- POST /import/mbox/:account_id - Import mbox file
- GET /import/mbox/:account_id - List mbox files
- DELETE /import/mbox/:id - Delete mbox file record

### Indexing & Search
- Query helper methods for testing
- Full-text search across all email content
- Nested EML content extraction and indexing
- Attachment metadata indexing

### Test Infrastructure
- Test mode configuration (#[cfg(not(test))] guards)
- Test-specific settings with auto-directory creation
- Mock mbox generator with 7 email types
- Comprehensive test suite with 13+ scenarios
- Tests for plain text, HTML, attachments, nested EML

## Technical Details

### Files Added
- src/modules/import/mbox.rs - Core import logic
- src/modules/mbox/migration.rs - Database entity (model ID: 9)
- src/modules/mbox/mod.rs - Module definition
- src/modules/import/mbox_mock.rs - Test data generator
- src/modules/import/mbox_comprehensive_test.rs - Integration tests
- src/modules/import/mbox_tests.rs - Simple tests
- CLAUDE.md - Comprehensive status documentation

### Files Modified
- Cargo.toml - Added mbox-reader dependency
- src/main.rs - Test mode guard
- src/modules/settings/cli.rs - Test configuration
- src/modules/database/mod.rs - Model registration
- src/modules/indexer/manager.rs - Query helpers + dual storage
- src/modules/rest/api/import.rs - REST endpoints
- src/modules/error/code.rs - Added IoError variant
- Multiple other files for integration

### Database Schema
- MboxFile entity with unique secondary keys (id, path)
- EML index tracks: mbox_id, mbox_offset, mbox_len
- mbox_id=0 marker for IMAP emails

### Test Coverage
- 7 distinct email types in mock data
- Unique searchable keywords per type
- Tests for content extraction at 3 nesting levels
- Attachment type validation (PDF, PNG, TXT, CSV, EML)

## Fixes Applied
- Fixed model ID conflict (MboxFile: 5→9, OAuth2 kept 5)
- Added test mode guards to prevent CLI arg parsing
- Auto-create test directories in test settings
- Registered MboxFile in database models

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

Co-Authored-By: Claude <noreply@anthropic.com>
@dagelf
Copy link
Author

dagelf commented Dec 6, 2025

Oops thought I was just merging with my own fork. I put Claude on this, haven't looked at what it has done at all, just let it run. I'm not super familiar with the codebase but asked for an overview and prompted best I could.

Json transcript FWIW 7587ad45-3b6b-444c-9ead-a013d1a49221.zip

Haven't had a chance to look and to try it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant