annotate calsync/gcalclient/event_requests.go @ 70:06f3aa9d461c

page size
author drewp@bigasterisk.com
date Fri, 06 Sep 2024 17:30:27 -0700
parents 8aee4f5c4bdd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
53
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
1 package gcalclient
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
2
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
3 import (
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
4 "time"
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
5
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
6 "google.golang.org/api/calendar/v3"
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
7 )
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
8
70
06f3aa9d461c page size
drewp@bigasterisk.com
parents: 61
diff changeset
9 const pageSize = 200
61
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
10 const notificationsUrl1 = "https://bigasterisk.com"
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
11 const notificationsUrl2 = "/gcalendarwatch/notifications"
53
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
12
57
24f662799710 WIP incremental sync now runs
drewp@bigasterisk.com
parents: 56
diff changeset
13 func rangedEventsCall(srv *calendar.Service, calGoogleId string, initialFillStart, initialFillEnd time.Time, pageToken string) *calendar.EventsListCall {
53
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
14 return srv.Events.List(calGoogleId).
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
15 ShowDeleted(false).
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
16 SingleEvents(true).
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
17 TimeMin(initialFillStart.Format(time.RFC3339)).
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
18 TimeMax(initialFillEnd.Format(time.RFC3339)).
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
19 MaxResults(pageSize).
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
20 PageToken(pageToken)
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
21 }
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
22
57
24f662799710 WIP incremental sync now runs
drewp@bigasterisk.com
parents: 56
diff changeset
23 func syncEventsCall(srv *calendar.Service, calGoogleId string, syncToken, pageToken string) *calendar.EventsListCall {
53
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
24 return srv.Events.List(calGoogleId).
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
25 ShowDeleted(true).
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
26 SingleEvents(true).
57
24f662799710 WIP incremental sync now runs
drewp@bigasterisk.com
parents: 56
diff changeset
27 MaxResults(pageSize).
24f662799710 WIP incremental sync now runs
drewp@bigasterisk.com
parents: 56
diff changeset
28 PageToken(pageToken).
24f662799710 WIP incremental sync now runs
drewp@bigasterisk.com
parents: 56
diff changeset
29 SyncToken(syncToken)
53
f248f018a663 refactor; dead code
drewp@bigasterisk.com
parents:
diff changeset
30 }
61
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
31
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
32 func watchEventsCall(srv *calendar.Service, calGoogleId string, expire time.Duration, watchId string) *calendar.EventsWatchCall {
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
33
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
34 return srv.Events.Watch(calGoogleId, &calendar.Channel{
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
35 Address: notificationsUrl1 + notificationsUrl2,
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
36 Expiration: (time.Now().Add(expire)).UnixMilli(),
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
37 Id: watchId,
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
38 Type: "web_hook",
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
39 })
8aee4f5c4bdd receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents: 57
diff changeset
40 }