From 9d89b4177a7504bd24d353151dc09362f17568d3 Mon Sep 17 00:00:00 2001 From: Brad Jones Date: Mon, 29 Dec 2025 14:55:23 -0800 Subject: [PATCH 1/3] Add OOO support - if the entire 2-hour window scanned is within an OOO block, that calendar is skipped. --- calendar.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/calendar.go b/calendar.go index fb53c0e..586e14a 100644 --- a/calendar.go +++ b/calendar.go @@ -149,6 +149,7 @@ func fetchEvents(now time.Time, srv *calendar.Service, userPrefs *UserPrefs) ([] for _, calendar := range userPrefs.Calendars { var locationCreated time.Time var location WorkSite + skip := false events, err := srv.Events.List(calendar).ShowDeleted(false). SingleEvents(true).TimeMin(start).TimeMax(end).OrderBy("startTime"). EventTypes("default", "focusTime", "outOfOffice", "workingLocation").Do() @@ -189,14 +190,31 @@ func fetchEvents(now time.Time, srv *calendar.Service, userPrefs *UserPrefs) ([] locations = append(locations, WorkSite{SiteType: locationType, Name: locationString}) } fmt.Fprintf(debugOut, "Location detected: calendar %v, location %v\n", calendar, location) + } else if event.EventType == "outOfOffice" { + // OOO events don't use an empty start time to indicate an all-day event. + // Instead, check if the start is before our current window and the end + // is after it ends, and if so, skip this entire calendar. + eventStart, err1 := time.Parse(time.RFC3339, event.Start.DateTime) + eventEnd, err2 := time.Parse(time.RFC3339, event.End.DateTime) + if err1 != nil || err2 != nil { + fmt.Fprintf(debugOut, "Skipping event %v because of time parse errors: %v, %v\n", event.Summary, err1, err2) + } + if eventStart.Before(now) && eventEnd.After(endTime) { + fmt.Fprintf(debugOut, "Skipping calendar %v due to OOO\n", calendar) + skip = true + } else { + fmt.Fprintf(debugOut, "Not applying OOO event %v to calendar %v because start is %v\n", event, calendar, event.Start.DateTime) + } } } - if !locationCreated.IsZero() { - fmt.Fprintf(debugOut, "Adding final location %v\n", location) - locations = append(locations, location) - fmt.Fprintf(debugOut, "Locations: %v\n", locations) + if !skip { + if !locationCreated.IsZero() { + fmt.Fprintf(debugOut, "Adding final location %v\n", location) + locations = append(locations, location) + fmt.Fprintf(debugOut, "Locations: %v\n", locations) + } + allEvents = append(allEvents, events.Items...) } - allEvents = append(allEvents, events.Items...) } if len(userPrefs.Calendars) > 1 { // Filter out copies of the same event, or ones with times that don't parse. From 991aa6ef09c94bac1e91c61c9f22de201571a192 Mon Sep 17 00:00:00 2001 From: Brad Jones Date: Mon, 29 Dec 2025 15:02:21 -0800 Subject: [PATCH 2/3] Skip the rest of the events in this calendar if OOO triggers. --- calendar.go | 1 + 1 file changed, 1 insertion(+) diff --git a/calendar.go b/calendar.go index 586e14a..aef5911 100644 --- a/calendar.go +++ b/calendar.go @@ -202,6 +202,7 @@ func fetchEvents(now time.Time, srv *calendar.Service, userPrefs *UserPrefs) ([] if eventStart.Before(now) && eventEnd.After(endTime) { fmt.Fprintf(debugOut, "Skipping calendar %v due to OOO\n", calendar) skip = true + break } else { fmt.Fprintf(debugOut, "Not applying OOO event %v to calendar %v because start is %v\n", event, calendar, event.Start.DateTime) } From c55fcd8dce84b510668197e63c6cc87df1f12b4f Mon Sep 17 00:00:00 2001 From: Brad Jones Date: Mon, 29 Dec 2025 15:13:10 -0800 Subject: [PATCH 3/3] Fix debug statement in the OOO case --- calendar.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/calendar.go b/calendar.go index aef5911..ddecd12 100644 --- a/calendar.go +++ b/calendar.go @@ -204,7 +204,7 @@ func fetchEvents(now time.Time, srv *calendar.Service, userPrefs *UserPrefs) ([] skip = true break } else { - fmt.Fprintf(debugOut, "Not applying OOO event %v to calendar %v because start is %v\n", event, calendar, event.Start.DateTime) + fmt.Fprintf(debugOut, "Not applying OOO event %v to calendar %v\n", event, calendar) } } }