mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-05-19 12:50:11 -05:00
443a797e2d
Implement comprehensive CalDAV calendar integration to import calendar events as time entries from CalDAV-compatible servers (Zimbra, Nextcloud, ownCloud). Features: - CalDAV client with calendar discovery and event fetching - Automatic calendar discovery from server URL - Import calendar events (VEVENT) as time entries - Project matching from event titles with fallback to default project - Idempotent sync using IntegrationExternalEventLink to prevent duplicates - Per-user integration setup (similar to Google Calendar) - Support for both server URL (with discovery) and direct calendar URL - SSL certificate verification toggle for self-signed certificates - Configurable lookback period for event import Components: - CalDAVCalendarConnector: Main integration connector with sync logic - CalDAVClient: Low-level CalDAV client using PROPFIND/REPORT requests - IntegrationExternalEventLink: Model for tracking imported events (idempotency) - Setup UI: User-friendly form for configuration - Comprehensive validation and error handling - Full test coverage (unit, integration, route tests) - Documentation: Setup guide and troubleshooting Technical details: - Uses icalendar library for parsing VEVENT components - Handles timezone conversion (CalDAV UTC to app local timezone) - Skips all-day events (only imports timed events) - Stores credentials securely (password in access_token, username in extra_data) - Automatic calendar discovery on first sync if only server URL provided Migration: - Adds integration_external_event_links table for sync tracking - Unique constraint on (integration_id, external_uid) prevents duplicates Documentation: - CALDAV_INTEGRATION.md: Complete feature documentation - CALDAV_QUICK_SETUP.md: Step-by-step setup guide with examples Closes feature request for CalDAV/Zimbra integration.
5.7 KiB
5.7 KiB
CalDAV Calendar Integration
The CalDAV integration allows you to import calendar events from CalDAV-compatible servers (such as Zimbra, Nextcloud, or ownCloud) as time entries in TimeTracker.
Features
- Calendar Discovery: Automatically discover available calendars on your CalDAV server
- Event Import: Import calendar events (VEVENT) as time entries
- Project Matching: Automatically match events to projects based on event titles
- Idempotent Sync: Prevents duplicate imports using event UIDs
- Flexible Configuration: Support for both server URL (with discovery) and direct calendar URL
Supported Servers
- Zimbra: Fully supported
- Nextcloud Calendar: Fully supported
- ownCloud Calendar: Fully supported
- Other CalDAV servers: Should work with any CalDAV-compatible server
Setup Instructions
1. Navigate to Integrations
- Go to Integrations from the main menu
- Find CalDAV Calendar in the list
- Click Setup CalDAV Calendar
2. Configure Server Connection
Option A: Using Server URL (Recommended)
-
Server URL: Enter your CalDAV server base URL
- Example for Zimbra:
https://mail.example.com/dav - Example for Nextcloud:
https://nextcloud.example.com/remote.php/dav
- Example for Zimbra:
-
The system will automatically discover your calendars
Option B: Using Direct Calendar URL
- Calendar URL: Enter the direct URL to your calendar collection
- Example:
https://mail.example.com/dav/user@example.com/Calendar/ - This bypasses discovery and connects directly to a specific calendar
- Example:
3. Authentication
- Username: Your CalDAV username (usually your email address)
- Password: Your CalDAV password or app-specific password
- Verify SSL: Check this box unless using a self-signed certificate
4. Import Settings
- Default Project: Select the project where imported events will be assigned
- If an event title contains a project name, that project will be used instead
- Lookback Days: How many days back to import events (default: 90)
5. Save and Test
- Click Save Configuration
- Go to the integration details page
- Click Test Connection to verify connectivity
- Click Sync Now to import calendar events
How It Works
Event Import Process
- The system fetches calendar events from your CalDAV server within the specified time range
- Each event is checked against existing imports (using event UID) to prevent duplicates
- Events are converted to time entries with:
- Start Time: Event start time
- End Time: Event end time
- Duration: Calculated automatically
- Project: Matched from event title or uses default project
- Notes: Event summary and description
- Source: Marked as "auto" (automatically imported)
Project Matching
The system attempts to match event titles to project names:
- If an event title contains a project name, that project is used
- Otherwise, the default project is used
- Example: Event "Meeting - Project Alpha" will be assigned to "Project Alpha" if it exists
Idempotency
Each calendar event has a unique UID. The system tracks imported events to prevent duplicates:
- First import: Event is imported as a new time entry
- Subsequent syncs: Event is skipped (already imported)
Zimbra-Specific Notes
Finding Your CalDAV URL
For Zimbra, the CalDAV URL typically follows this pattern:
https://mail.yourdomain.com/dav/username@yourdomain.com/Calendar/
Authentication
- Use your Zimbra email address as the username
- Use your Zimbra password (or an app-specific password if enabled)
Calendar Discovery
If you provide the server URL (https://mail.yourdomain.com/dav), the system will:
- Discover your user principal
- Find your calendar home set
- List all available calendars
- Allow you to select which calendar to sync
Troubleshooting
Connection Test Fails
- Check Server URL: Ensure the URL is correct and accessible
- Verify Credentials: Double-check username and password
- SSL Certificate: If using self-signed certificate, uncheck "Verify SSL"
- Firewall: Ensure your server allows CalDAV connections (usually port 443)
No Events Imported
- Check Time Range: Events must be within the lookback period
- Verify Calendar URL: Ensure the calendar URL is correct
- Check Event Types: Only timed events (not all-day events) are imported
- Review Sync Log: Check the integration details page for error messages
Duplicate Events
- The system prevents duplicates using event UIDs
- If you see duplicates, they may have different UIDs (rare)
- Check the integration sync history for details
Limitations
- One-Way Sync: Currently only imports from calendar to TimeTracker (not bidirectional)
- Timed Events Only: All-day events are skipped
- No Recurring Events: Recurring events are imported as individual instances
- Manual Sync: Automatic sync is not yet implemented (use "Sync Now" button)
Future Enhancements
Planned features:
- Bidirectional sync (TimeTracker → Calendar)
- Automatic periodic sync
- Support for all-day events
- Better project matching with tags/categories
- Event updates (modify time entries when calendar events change)
Security Notes
- Passwords are stored encrypted in the database
- SSL verification is enabled by default (recommended)
- Only events from your configured calendar are accessed
- No calendar data is shared with third parties
Support
For issues or questions:
- Check the integration sync history for error messages
- Review server logs for connection issues
- Test connection using the "Test Connection" button
- Contact your system administrator if problems persist