update docs.
This commit is contained in:
@@ -4,12 +4,29 @@
|
||||
|
||||
This document outlines the specification for implementing a feature to persistently track which emails have been processed by the Email Organizer system. The goal is to maintain a record of email processing status to avoid reprocessing the same emails during synchronization and provide accurate pending email counts.
|
||||
|
||||
## Current Implementation Status
|
||||
|
||||
The Processed Emails feature is fully implemented and operational:
|
||||
|
||||
### Core Implementation
|
||||
- **ProcessedEmail Model**: Implemented in [`app/models.py`](app/models.py:51)
|
||||
- **ProcessedEmails Service**: Implemented in [`app/processed_emails_service.py`](app/processed_emails_service.py:7)
|
||||
- **Emails Blueprint**: Implemented in [`app/routes/emails.py`](app/routes/emails.py:1)
|
||||
- **UI Integration**: Pending emails dialog and processing functionality
|
||||
|
||||
### Key Features
|
||||
- Email UID tracking for processing status
|
||||
- Pending email counts and management
|
||||
- Bulk email processing operations
|
||||
- Email metadata display and management
|
||||
- Integration with IMAP synchronization process
|
||||
|
||||
## Requirements
|
||||
|
||||
### 1. Email Tracking Requirements
|
||||
|
||||
- **Unique Email Identification**: Track emails using a unique identifier (UID) provided by the IMAP server, along with the folder name and user ID
|
||||
- **Processing Status**: Mark emails as either "pending" (unprocessed) or "processed"
|
||||
- **Processing Status**: Mark emails as either "pending" (unprocessed) or "processed"
|
||||
- **Minimal Data Storage**: Store only essential information - email UID, folder, user, and processing status - not email content, subjects, or bodies
|
||||
- **Persistence**: Maintain processing status across application restarts and synchronization cycles
|
||||
- **Efficient Lookup**: Quickly determine which emails in a folder are pending processing
|
||||
@@ -19,7 +36,7 @@ This document outlines the specification for implementing a feature to persisten
|
||||
- **Initial Sync**: During first synchronization of a folder, all emails should be marked as "pending"
|
||||
- **Incremental Sync**: On subsequent syncs, only emails that haven't been processed should be identified as pending
|
||||
- **Status Update**: When an email is processed, update its status from "pending" to "processed"
|
||||
- **Cleanup**: Remove records for emails that no longer exist on the IMAP server (optional for future enhancement)
|
||||
- **Cleanup**: Remove records for emails that no longer exist on the IMAP server
|
||||
|
||||
### 3. Performance Requirements
|
||||
|
||||
@@ -110,7 +127,7 @@ erDiagram
|
||||
|
||||
### ProcessedEmailsService
|
||||
|
||||
A new service class will be responsible for managing processed email records:
|
||||
The ProcessedEmailsService ([`app/processed_emails_service.py`](app/processed_emails_service.py:7)) provides:
|
||||
|
||||
```python
|
||||
class ProcessedEmailsService:
|
||||
@@ -138,7 +155,7 @@ class ProcessedEmailsService:
|
||||
|
||||
### IMAPService Integration
|
||||
|
||||
The existing IMAP service will be enhanced to use the ProcessedEmailsService:
|
||||
The IMAP service ([`app/imap_service.py`](app/imap_service.py:11)) integrates with the ProcessedEmailsService:
|
||||
|
||||
```python
|
||||
class IMAPService:
|
||||
@@ -160,18 +177,31 @@ class IMAPService:
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### New HTMX Endpoints for Processed Email Management
|
||||
### HTMX Endpoints for Processed Email Management
|
||||
|
||||
1. **Get Pending Emails for a Folder**
|
||||
- Method: GET
|
||||
- Path: `/api/folders/<folder_id>/pending-emails`
|
||||
- Response: An Dialog List of email metadata for pending emails (subject, date, UID), a button to preview the email (fetch it from the imap server)
|
||||
- Response: Dialog with list of email metadata for pending emails (subject, date, UID)
|
||||
- Features: Email preview, individual processing buttons
|
||||
|
||||
2. **Mark Email as Processed**
|
||||
- Method: POST
|
||||
- Path: `/api/folders/<folder_id>/emails/<email_uid>/process`
|
||||
- Action: Mark a specific email as processed
|
||||
- Response: Updated dialog body.
|
||||
- Response: Updated dialog body with new counts
|
||||
|
||||
3. **Sync Emails for a Folder**
|
||||
- Method: POST
|
||||
- Path: `/api/folders/<folder_id>/sync-emails`
|
||||
- Action: Sync emails for a specific folder with processed email tracking
|
||||
- Response: Updated counts and sync status
|
||||
|
||||
4. **Process Multiple Emails**
|
||||
- Method: POST
|
||||
- Path: `/api/folders/<folder_id>/process-emails`
|
||||
- Action: Process multiple emails in a folder (mark as processed)
|
||||
- Response: Success message with updated counts
|
||||
|
||||
## Workflow Integration
|
||||
|
||||
@@ -218,25 +248,27 @@ sequenceDiagram
|
||||
|
||||
## Migration Strategy
|
||||
|
||||
### Phase 1: Data Model Implementation
|
||||
1. Create the `processed_emails` table with appropriate indexes
|
||||
2. Implement the `ProcessedEmailsService` class
|
||||
3. Add basic CRUD operations for email processing records
|
||||
### Current Implementation Status
|
||||
|
||||
### Phase 2: IMAP Service Integration
|
||||
1. Update `IMAPService` to use `ProcessedEmailsService`
|
||||
2. Modify folder synchronization to track email UIDs
|
||||
3. Update email count methods to consider processing status
|
||||
#### Phase 1: Data Model Implementation ✅
|
||||
1. Create the `processed_emails` table with appropriate indexes ✅
|
||||
2. Implement the `ProcessedEmailsService` class ✅
|
||||
3. Add basic CRUD operations for email processing records ✅
|
||||
|
||||
### Phase 3: API and UI Integration
|
||||
1. Add API endpoints for processed email management
|
||||
2. Update UI to display accurate pending counts
|
||||
3. Add bulk processing capabilities
|
||||
#### Phase 2: IMAP Service Integration ✅
|
||||
1. Update `IMAPService` to use `ProcessedEmailsService` ✅
|
||||
2. Modify folder synchronization to track email UIDs ✅
|
||||
3. Update email count methods to consider processing status ✅
|
||||
|
||||
### Phase 4: Optimization and Cleanup
|
||||
1. Implement batch processing for performance
|
||||
2. Add periodic cleanup of orphaned records
|
||||
3. Optimize database queries for large datasets
|
||||
#### Phase 3: API and UI Integration ✅
|
||||
1. Add API endpoints for processed email management ✅
|
||||
2. Update UI to display accurate pending counts ✅
|
||||
3. Add bulk processing capabilities ✅
|
||||
|
||||
#### Phase 4: Optimization and Cleanup ✅
|
||||
1. Implement batch processing for performance ✅
|
||||
2. Add periodic cleanup of orphaned records ✅
|
||||
3. Optimize database queries for large datasets ✅
|
||||
|
||||
## Security Considerations
|
||||
|
||||
|
||||
Reference in New Issue
Block a user