From 165d866cfc8aeef9cad5e3e35c634815123b8271 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 5 Aug 2016 15:01:21 -0400 Subject: [PATCH] (fix) correctly calculate recurrence exceptions when not overlapping the recurrence id --- NEWS | 1 + .../Appointments/SOGoAppointmentFolder.m | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 48730fe62..e4036c29d 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ Bug fixes - [web] really delete mailboxes being deleted from the Trash folder (#595, #1189, #641) - [core] fixing sogo-tool backup with multi-domain configuration but domain-less logins - [core] during event scheduling, use 409 instead of 403 so Lightning doesn't fail silently + - [core] correctly calculate recurrence exceptions when not overlapping the recurrence id 2.3.13 (2016-07-06) ------------------- diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index df0916194..e9a795b04 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -979,12 +979,16 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir withTimeZone: (NSTimeZone *) tz toArray: (NSMutableArray *) ma { + NGCalendarDateRange *recurrenceIdRange; NSCalendarDate *recurrenceId; NSMutableDictionary *newRecord; NGCalendarDateRange *newRecordRange; NSComparisonResult compare; - int recordIndex, secondsOffsetFromGMT; NSNumber *dateSecs; + id master; + + int recordIndex, secondsOffsetFromGMT; + NSTimeInterval delta; newRecord = nil; recurrenceId = [component recurrenceId]; @@ -1006,17 +1010,20 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir [recurrenceId setTimeZone: tz]; } - compare = [[dateRange startDate] compare: recurrenceId]; - if ((compare == NSOrderedAscending || compare == NSOrderedSame) && - [[dateRange endDate] compare: recurrenceId] == NSOrderedDescending) + master = [[[component parent] events] objectAtIndex: 0]; + delta = [[master endDate] timeIntervalSinceDate: [master startDate]]; + recurrenceIdRange = [NGCalendarDateRange calendarDateRangeWithStartDate: recurrenceId + endDate: [recurrenceId dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds: delta]]; + if ([dateRange doesIntersectWithDateRange: recurrenceIdRange]) { // The recurrence exception intersects with the date range; // find the occurence and replace it with the new record recordIndex = [self _indexOfRecordMatchingDate: recurrenceId inArray: ma]; if (recordIndex > -1) { - if ([dateRange containsDate: [component startDate]]) - { + if ([dateRange containsDate: [component startDate]] || + [dateRange containsDate: [component endDate]]) + { // We must pass nil to :container here in order to avoid re-entrancy issues. newRecord = [self _fixupRecord: [component quickRecordFromContent: nil container: nil]]; [ma replaceObjectAtIndex: recordIndex withObject: newRecord];