Mercurial > code > home > repos > gcalendarwatch
diff calsync/gcalclient/event_requests.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 | 24f662799710 |
children | 06f3aa9d461c |
line wrap: on
line diff
--- a/calsync/gcalclient/event_requests.go Fri Sep 06 16:41:48 2024 -0700 +++ b/calsync/gcalclient/event_requests.go Fri Sep 06 16:43:14 2024 -0700 @@ -7,6 +7,8 @@ ) const pageSize = 20 +const notificationsUrl1 = "https://bigasterisk.com" +const notificationsUrl2 = "/gcalendarwatch/notifications" func rangedEventsCall(srv *calendar.Service, calGoogleId string, initialFillStart, initialFillEnd time.Time, pageToken string) *calendar.EventsListCall { return srv.Events.List(calGoogleId). @@ -26,3 +28,13 @@ PageToken(pageToken). SyncToken(syncToken) } + +func watchEventsCall(srv *calendar.Service, calGoogleId string, expire time.Duration, watchId string) *calendar.EventsWatchCall { + + return srv.Events.Watch(calGoogleId, &calendar.Channel{ + Address: notificationsUrl1 + notificationsUrl2, + Expiration: (time.Now().Add(expire)).UnixMilli(), + Id: watchId, + Type: "web_hook", + }) +}