diff calsync/main.go @ 61:8aee4f5c4bdd

receive notifications and route them to calendar sync functions
author drewp@bigasterisk.com
date Fri, 06 Sep 2024 16:43:14 -0700
parents 3b0595c2bf03
children 329144c7e711
line wrap: on
line diff
--- a/calsync/main.go	Fri Sep 06 16:41:48 2024 -0700
+++ b/calsync/main.go	Fri Sep 06 16:43:14 2024 -0700
@@ -24,6 +24,7 @@
 
 	"bigasterisk.com/go/gcalendarwatch/gcalclient"
 	"bigasterisk.com/go/gcalendarwatch/mongoclient"
+	"bigasterisk.com/go/gcalendarwatch/notificationrouter"
 	"github.com/gorilla/mux"
 )
 
@@ -43,6 +44,8 @@
 	}
 	defer mc.Close()
 
+	notifications := notificationrouter.New()
+
 	// todo: if a cal is deleted, we don't clean up its events, even upon
 	// restart.
 	err = updateMongoCalsToMatchGoogleOnce(mc, gc)
@@ -50,9 +53,9 @@
 		log.Fatal(err)
 	}
 
-	err = updateMongoEventsToMatchGoogleForever(mc, gc,
-		time.Duration(7*24)*time.Hour, 
-		time.Duration(14*24)*time.Hour)
+	initialSyncBack := (7 * 24) * time.Hour
+	initialSyncAhead := (14 * 24) * time.Hour
+	err = updateMongoEventsToMatchGoogleForever(mc, gc, initialSyncBack, initialSyncAhead, notifications)
 	if err != nil {
 		log.Fatal(err)
 	}