forked from aksdb/CalAnonSync
Fixed the way cancellation is determined (fixes #3)
This commit is contained in:
parent
fd0f4bf3c3
commit
3f84913b74
|
@ -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
|
||||
|
|
|
@ -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(`<?xml ver
|
|||
<t:FieldURI FieldURI="calendar:End" />
|
||||
<t:FieldURI FieldURI="calendar:UID" />
|
||||
<t:FieldURI FieldURI="calendar:RecurrenceId" />
|
||||
<t:FieldURI FieldURI="calendar:IsCancelled" />
|
||||
<t:FieldURI FieldURI="calendar:AppointmentState" />
|
||||
<t:FieldURI FieldURI="calendar:CalendarItemType" />
|
||||
<t:FieldURI FieldURI="calendar:IsAllDayEvent" />
|
||||
</t:AdditionalProperties>
|
||||
|
|
Loading…
Reference in New Issue