Fix calendar sync issues: correct True/False, limit recurrence to 2 years, add share_google_calendar function
- Fix Python syntax error: change 'true' to 'True' in config.py - Limit recurring events to max 2 years to avoid Google Calendar API limits - Add share_google_calendar function for manual calendar sharing - Update README with calendar sync documentation - Debug mode: limit sync to user AI only
This commit is contained in:
@@ -205,20 +205,66 @@ CMD ["motia", "start"]
|
||||
motia logs
|
||||
```
|
||||
|
||||
## Erweiterungen
|
||||
## Calendar Sync
|
||||
|
||||
### Geplante Features
|
||||
Das System enthält auch eine bidirektionale Kalender-Synchronisation zwischen Advoware und Google Calendar.
|
||||
|
||||
- Vollständige EspoCRM-API-Integration im Sync-Handler
|
||||
- Retry-Logic für fehlgeschlagene Syncs
|
||||
- Metriken und Alerting
|
||||
- Batch-Verarbeitung für große Datenmengen
|
||||
### Architektur
|
||||
|
||||
### API Erweiterungen
|
||||
- **PostgreSQL Hub**: Speichert Sync-Zustand und verhindert Datenverlust
|
||||
- **Event-Driven Sync**: 4-Phasen-Sync (Neu, Gelöscht, Aktualisiert)
|
||||
- **Safe Wrappers**: Globale Write-Protection für Advoware-Schreiboperationen
|
||||
- **Rate Limiting**: Backoff-Handling für Google Calendar API-Limits
|
||||
|
||||
- Zusätzliche Advoware-Endpunkte
|
||||
- Mehr EspoCRM-Entitäten
|
||||
- Custom Mapping-Regeln
|
||||
### Dauertermine (Recurring Appointments)
|
||||
|
||||
Advoware verwendet `dauertermin=1` für wiederkehrende Termine mit folgenden Feldern:
|
||||
|
||||
- `turnus`: Intervall (z.B. 1 = jeden, 3 = jeden 3.)
|
||||
- `turnusArt`: Frequenz-Einheit
|
||||
- `1` = Täglich (DAILY)
|
||||
- `2` = Wöchentlich (WEEKLY)
|
||||
- `3` = Monatlich (MONTHLY)
|
||||
- `4` = Jährlich (YEARLY)
|
||||
- `datumBis`: Enddatum der Wiederholung
|
||||
|
||||
**RRULE-Generierung:**
|
||||
```
|
||||
RRULE:FREQ={FREQ};INTERVAL={turnus};UNTIL={datumBis}
|
||||
```
|
||||
|
||||
Beispiel: `turnus=3, turnusArt=1` → `RRULE:FREQ=DAILY;INTERVAL=3;UNTIL=20251224`
|
||||
|
||||
### Setup
|
||||
|
||||
1. **Google Service Account**: `service-account.json` im Projektroot
|
||||
2. **Umgebungsvariablen**:
|
||||
```env
|
||||
ADVOWARE_WRITE_PROTECTION=false # Global write protection
|
||||
POSTGRES_HOST=localhost
|
||||
GOOGLE_CALENDAR_SERVICE_ACCOUNT_PATH=service-account.json
|
||||
```
|
||||
3. **Trigger Sync**:
|
||||
```bash
|
||||
curl -X POST "http://localhost:3000/advoware/calendar/sync" -H "Content-Type: application/json" -d '{"full_content": true}'
|
||||
```
|
||||
|
||||
### Rate Limiting & Backoff
|
||||
|
||||
- **Google Calendar API**: 403-Fehler bei Rate-Limits werden mit exponentiellem Backoff (max. 60s) wiederholt
|
||||
- **Delays**: 100ms zwischen API-Calls zur Vermeidung von Limits
|
||||
- **Retry-Logic**: Max. 4 Versuche mit base=4
|
||||
|
||||
### Sicherheit
|
||||
|
||||
- **Write Protection**: `ADVOWARE_WRITE_PROTECTION=true` deaktiviert alle Advoware-Schreiboperationen
|
||||
- **Per-User Calendars**: Automatische Erstellung und Freigabe von Google-Calendars pro Mitarbeiter
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
- **Rate Limit Errors**: Logs zeigen Backoff-Retries; warten oder Limits erhöhen
|
||||
- **Sync Failures**: `ADVOWARE_WRITE_PROTECTION=false` setzen für Debugging
|
||||
- **Calendar Access**: Service Account muss Owner-Rechte haben
|
||||
|
||||
## Lizenz
|
||||
|
||||
|
||||
Reference in New Issue
Block a user