diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 7c2ea30..064a0a9 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -376,25 +376,29 @@ pub async fn fetch_events(&self, calendar: &CalendarInfo) -> CalDavResult>, + pub imported_events: HashMap, // source_uid → target_href + pub deleted_events: HashSet, // Deleted source events + } + ``` + +**Phase 2: Import Logic (2-3 days)** +1. **Import Pipeline Algorithm** + ```rust + async fn import_events(&mut self) -> Result { + // 1. Fetch source events + let source_events = self.source_client.get_events(...).await?; + + // 2. Fetch target events + let target_events = self.target_client.get_events(...).await?; + + // 3. Process each source event (source wins) + for source_event in source_events { + if let Some(target_href) = self.import_state.imported_events.get(&source_event.uid) { + // UPDATE: Overwrite target with source data + self.update_target_event(source_event, target_href).await?; + } else { + // CREATE: New event in target + self.create_target_event(source_event).await?; + } + } + + // 4. DELETE: Remove orphaned target events + self.delete_orphaned_events(source_events, target_events).await?; + } + ``` + +2. **Target Calendar Management** + - Validate target calendar exists before import + - Set calendar properties (color, name, timezone) + - Fail fast if target calendar is not found + - Auto-creation as future enhancement (nice-to-have) + +3. **Event Transformation** + - Convert between iCalendar formats if needed + - Preserve timezone information + - Handle UID mapping for future updates + +**Phase 3: CLI & User Experience (1-2 days)** +1. **Import Commands** + ```bash + # Import events (dry run by default) + cargo run -- --import-events --dry-run + + # Execute actual import + cargo run -- --import-events --target-calendar "Imported-Zoho-Events" + + # List import status + cargo run -- --import-status + ``` + +2. **Progress Reporting** + - Real-time import progress + - Summary statistics (created/updated/deleted) + - Error reporting and recovery + +3. **Configuration Examples** + ```toml + [source] + server_url = "https://caldav.zoho.com/caldav" + username = "user@zoho.com" + password = "zoho-app-password" + + [target] + server_url = "https://nextcloud.example.com" + username = "nextcloud-user" + password = "nextcloud-app-password" + + [source_calendar] + name = "Work Calendar" + + [target_calendar] + name = "Imported-Work-Events" + create_if_missing = true + color = "#3174ad" + + [import] + overwrite_existing = true # Source always wins + delete_missing = true # Remove events not in source + dry_run = false + batch_size = 50 + ``` + +#### **Key Implementation Principles** + +1. **Source is Always Truth**: Source server data overwrites target +2. **Unidirectional Flow**: No bidirectional sync complexity +3. **Robust Error Handling**: Continue import even if some events fail +4. **Progress Visibility**: Clear reporting of import operations +5. **Configuration Flexibility**: Support for any CalDAV source/target + +#### **Estimated Timeline** +- **Phase 1**: 2-3 days (Core infrastructure) +- **Phase 2**: 2-3 days (Import logic) +- **Phase 3**: 1-2 days (CLI & UX) +- **Total**: 5-8 days for complete implementation + +#### **Success Criteria** +- Successfully import events from Zoho to Nextcloud +- Handle timezone preservation during import +- Provide clear progress reporting +- Support dry-run mode for preview +- Handle large calendars (1000+ events) efficiently + +This plan provides a clear roadmap for implementing the unidirectional event import feature while maintaining the simplicity and reliability of the current codebase. ### 🎉 **Final Status**