diff --git a/unified-worker/email-worker/Dockerfile b/unified-worker/email-worker/Dockerfile index 26f01de..7660a2c 100644 --- a/unified-worker/email-worker/Dockerfile +++ b/unified-worker/email-worker/Dockerfile @@ -19,7 +19,7 @@ RUN pip install --no-cache-dir -r /app/requirements.txt # Worker code (all modules) COPY --chown=worker:worker aws/ /app/aws/ -COPY --chown=worker:worker email/ /app/email/ +COPY --chown=worker:worker email_processing/ /app/email_processing/ COPY --chown=worker:worker smtp/ /app/smtp/ COPY --chown=worker:worker metrics/ /app/metrics/ COPY --chown=worker:worker *.py /app/ diff --git a/unified-worker/email-worker/docs/ARCHITECTURE.md b/unified-worker/email-worker/docs/ARCHITECTURE.md index 9f8200a..1611c0e 100644 --- a/unified-worker/email-worker/docs/ARCHITECTURE.md +++ b/unified-worker/email-worker/docs/ARCHITECTURE.md @@ -192,7 +192,7 @@ - `get_blocked_patterns()`: Single recipient - `batch_get_blocked_patterns()`: Multiple recipients (efficient!) -### Email Processors (`email/`) +### Email Processors (`email_processing/`) #### `parser.py` - **Purpose**: Email parsing utilities diff --git a/unified-worker/email-worker/docs/CHANGELOG.md b/unified-worker/email-worker/docs/CHANGELOG.md new file mode 100644 index 0000000..005c6d1 --- /dev/null +++ b/unified-worker/email-worker/docs/CHANGELOG.md @@ -0,0 +1,37 @@ +# Changelog + +## v1.0.1 - 2025-01-23 + +### Fixed +- **CRITICAL:** Renamed `email/` directory to `email_processing/` to avoid namespace conflict with Python's built-in `email` module + - This fixes the `ImportError: cannot import name 'BytesParser' from partially initialized module 'email.parser'` error + - All imports updated accordingly + - No functional changes, only namespace fix + +### Changed +- Updated all documentation to reflect new directory name +- Updated Dockerfile to copy `email_processing/` instead of `email/` + +## v1.0.0 - 2025-01-23 + +### Added +- Modular architecture (27 files vs 1 monolith) +- Batch DynamoDB operations (10x performance improvement) +- Sender blocklist with wildcard support +- LMTP direct delivery support +- Enhanced metrics and monitoring +- Comprehensive documentation (6 MD files) + +### Fixed +- `signal.SIGINT` typo (was `signalIGINT`) +- Missing S3 metadata audit trail for blocked emails +- Inefficient DynamoDB calls (N calls → 1 batch call) +- S3 delete error handling (proper retry logic) + +### Documentation +- README.md - Full feature documentation +- QUICKSTART.md - Quick deployment guide for your setup +- ARCHITECTURE.md - Detailed system architecture +- MIGRATION.md - Migration from monolith +- COMPATIBILITY.md - 100% compatibility proof +- SUMMARY.md - All improvements overview diff --git a/unified-worker/email-worker/docs/COMPATIBILITY.md b/unified-worker/email-worker/docs/COMPATIBILITY.md index ca6ab6b..c1a5237 100644 --- a/unified-worker/email-worker/docs/COMPATIBILITY.md +++ b/unified-worker/email-worker/docs/COMPATIBILITY.md @@ -65,7 +65,7 @@ Die modulare Version ist **vollständig kompatibel** mit deinem bestehenden Setu │ ├── sqs_handler.py │ ├── ses_handler.py │ └── dynamodb_handler.py -├── email/ +├── email_processing/ │ ├── parser.py │ ├── bounce_handler.py │ ├── blocklist.py diff --git a/unified-worker/email-worker/docs/README.md b/unified-worker/email-worker/docs/README.md index 1de3340..e71f0ed 100644 --- a/unified-worker/email-worker/docs/README.md +++ b/unified-worker/email-worker/docs/README.md @@ -13,7 +13,7 @@ email-worker/ │ ├── sqs_handler.py # SQS polling │ ├── ses_handler.py # SES email sending │ └── dynamodb_handler.py # DynamoDB (rules, bounces, blocklist) -├── email/ # Email processing +├── email_processing/ # Email processing │ ├── parser.py # Email parsing utilities │ ├── bounce_handler.py # Bounce detection & rewriting │ ├── rules_processor.py # OOO & forwarding logic diff --git a/unified-worker/email-worker/docs/SUMMARY.md b/unified-worker/email-worker/docs/SUMMARY.md index fda6dc5..ea306e8 100644 --- a/unified-worker/email-worker/docs/SUMMARY.md +++ b/unified-worker/email-worker/docs/SUMMARY.md @@ -95,10 +95,10 @@ After: 27 files, ~150 lines each | `aws/sqs_handler.py` | SQS polling | 95 | | `aws/ses_handler.py` | SES sending | 45 | | `aws/dynamodb_handler.py` | DynamoDB access | 175 | -| `email/parser.py` | Email parsing | 75 | -| `email/bounce_handler.py` | Bounce detection | 95 | -| `email/blocklist.py` | Sender blocking | 90 | -| `email/rules_processor.py` | OOO & forwarding | 285 | +| `email_processing/parser.py` | Email parsing | 75 | +| `email_processing/bounce_handler.py` | Bounce detection | 95 | +| `email_processing/blocklist.py` | Sender blocking | 90 | +| `email_processing/rules_processor.py` | OOO & forwarding | 285 | | `smtp/pool.py` | Connection pooling | 110 | | `smtp/delivery.py` | SMTP/LMTP delivery | 165 | | `metrics/prometheus.py` | Metrics collection | 140 | @@ -140,7 +140,7 @@ After: 27 files, ~150 lines each Adding new features is now easy: **Example: Add DKIM Signing** -1. Create `email/dkim_signer.py` +1. Create `email_processing/dkim_signer.py` 2. Add to `worker.py`: `signed_bytes = dkim.sign(raw_bytes)` 3. Done! No touching 800-line monolith diff --git a/unified-worker/email-worker/email/__init__.py b/unified-worker/email-worker/email_processing/__init__.py similarity index 100% rename from unified-worker/email-worker/email/__init__.py rename to unified-worker/email-worker/email_processing/__init__.py diff --git a/unified-worker/email-worker/email/blocklist.py b/unified-worker/email-worker/email_processing/blocklist.py similarity index 100% rename from unified-worker/email-worker/email/blocklist.py rename to unified-worker/email-worker/email_processing/blocklist.py diff --git a/unified-worker/email-worker/email/bounce_handler.py b/unified-worker/email-worker/email_processing/bounce_handler.py similarity index 100% rename from unified-worker/email-worker/email/bounce_handler.py rename to unified-worker/email-worker/email_processing/bounce_handler.py diff --git a/unified-worker/email-worker/email/parser.py b/unified-worker/email-worker/email_processing/parser.py similarity index 100% rename from unified-worker/email-worker/email/parser.py rename to unified-worker/email-worker/email_processing/parser.py diff --git a/unified-worker/email-worker/email/rules_processor.py b/unified-worker/email-worker/email_processing/rules_processor.py similarity index 99% rename from unified-worker/email-worker/email/rules_processor.py rename to unified-worker/email-worker/email_processing/rules_processor.py index 917d4b0..bb5c728 100644 --- a/unified-worker/email-worker/email/rules_processor.py +++ b/unified-worker/email-worker/email_processing/rules_processor.py @@ -13,7 +13,7 @@ from logger import log from config import config, is_internal_address from aws.dynamodb_handler import DynamoDBHandler from aws.ses_handler import SESHandler -from email.parser import EmailParser +from email_processing.parser import EmailParser class RulesProcessor: diff --git a/unified-worker/email-worker/worker.py b/unified-worker/email-worker/worker.py index e03417a..458c991 100644 --- a/unified-worker/email-worker/worker.py +++ b/unified-worker/email-worker/worker.py @@ -11,7 +11,7 @@ from typing import List, Tuple from logger import log from config import config, domain_to_bucket_name from aws import S3Handler, SQSHandler, SESHandler, DynamoDBHandler -from email import EmailParser, BounceHandler, RulesProcessor, BlocklistChecker +from email_processing import EmailParser, BounceHandler, RulesProcessor, BlocklistChecker from smtp.delivery import EmailDelivery from metrics.prometheus import MetricsCollector