diff --git a/src/calanonsync/calanonsync.go b/src/calanonsync/calanonsync.go index 22ee4fa..6120322 100644 --- a/src/calanonsync/calanonsync.go +++ b/src/calanonsync/calanonsync.go @@ -25,7 +25,7 @@ func main() { for _, item := range items { // Ignore private items. - if item.Sensitivity != "Private" && !item.IsCancelled { + if item.Sensitivity != "Private" && !item.IsCancelled() { // None-private items though ... remember them by hash. // The hash will equal the CalDAV UID (and its filename). relevantEWSItems[item.Hash()] = item diff --git a/src/calanonsync/ews.go b/src/calanonsync/ews.go index 4b0f797..a7c11ad 100644 --- a/src/calanonsync/ews.go +++ b/src/calanonsync/ews.go @@ -29,10 +29,18 @@ type CalendarItem struct { RecurrenceId string Sensitivity string CalendarItemType string - IsCancelled bool + AppointmentState AppointmentState IsAllDayEvent bool } +type AppointmentState int + +const ( + AppointmentStateMeeting AppointmentState = 1 << iota // This appointment is a meeting. + AppointmentStateReceived // This appointment has been received. + AppointmentStateCancelled // This appointment has been canceled. +) + // Build a hash for the given calendar item by combining the UID and // the recurrenceId therefore guaranteeing a unique identifier for the // event, even if it has been a calculated recurrence (which would @@ -44,6 +52,10 @@ func (ci CalendarItem) Hash() string { return strings.ToUpper(hex.EncodeToString(h.Sum(nil))) } +func (ci CalendarItem) IsCancelled() bool { + return ci.AppointmentState&AppointmentStateCancelled != 0 +} + type EWSCalendar struct { httpClient *http.Client url string @@ -262,7 +274,7 @@ var calendarQuery = template.Must(template.New("calendarQuery").Parse(` - +