Implements CalDAV sync using github.com/emersion/go-webdav: - CalDAVService with background polling (configurable per-tenant interval) - Push: deadlines -> VTODO, appointments -> VEVENT on create/update/delete - Pull: periodic fetch from CalDAV, reconcile with local DB - Conflict resolution: KanzlAI wins dates/status, CalDAV wins notes/description - Conflicts logged as case_events with caldav_conflict type - UID pattern: kanzlai-{deadline|appointment}-{uuid}@kanzlai.msbls.de - CalDAV config per tenant in tenants.settings JSONB Endpoints: - POST /api/caldav/sync — trigger full sync for current tenant - GET /api/caldav/status — last sync time, item counts, errors 8 unit tests for UID generation, parsing, path construction, config parsing.
40 lines
933 B
Go
40 lines
933 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"mgit.msbls.de/m/KanzlAI-mGMT/internal/auth"
|
|
"mgit.msbls.de/m/KanzlAI-mGMT/internal/config"
|
|
"mgit.msbls.de/m/KanzlAI-mGMT/internal/db"
|
|
"mgit.msbls.de/m/KanzlAI-mGMT/internal/router"
|
|
"mgit.msbls.de/m/KanzlAI-mGMT/internal/services"
|
|
)
|
|
|
|
func main() {
|
|
cfg, err := config.Load()
|
|
if err != nil {
|
|
log.Fatalf("Failed to load config: %v", err)
|
|
}
|
|
|
|
database, err := db.Connect(cfg.DatabaseURL)
|
|
if err != nil {
|
|
log.Fatalf("Failed to connect to database: %v", err)
|
|
}
|
|
defer database.Close()
|
|
|
|
authMW := auth.NewMiddleware(cfg.SupabaseJWTSecret, database)
|
|
|
|
// Start CalDAV sync service
|
|
calDAVSvc := services.NewCalDAVService(database)
|
|
calDAVSvc.Start()
|
|
defer calDAVSvc.Stop()
|
|
|
|
handler := router.New(database, authMW, cfg, calDAVSvc)
|
|
|
|
log.Printf("Starting KanzlAI API server on :%s", cfg.Port)
|
|
if err := http.ListenAndServe(":"+cfg.Port, handler); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|