From 6ffc48d2793c41d8db6496504e3e2c5d4fcac7d1 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 19 Dec 2008 23:04:26 +0000 Subject: [PATCH] Same as the fix for the postCalDAVEventRequestTo:from: method. Monotone-Parent: d0d94f5dbbc0725b57437eef5366686ec0842d97 Monotone-Revision: 594291b61ba62cd40f6c3250f748a5fe7b2514a3 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2008-12-19T23:04:26 Monotone-Branch: ca.inverse.sogo --- .../Appointments/SOGoAppointmentObject.m | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 2906d5cbb..b7fb084a6 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -200,7 +200,55 @@ NSString *iCalString; object = [self _lookupEvent: [theEvent uid] forUID: theUID]; - iCalString = [[theEvent parent] versitString]; + + // We must add an occurence to a non-existing event. We have + // to handle this with care, as in the postCalDAVEventRequestTo:from: + if ([object isNew] && [theEvent recurrenceId]) + { + SOGoAppointmentObject *ownerEventObject; + NSArray *attendees; + iCalPerson *person; + SOGoUser *user; + BOOL found; + int i; + + user = [SOGoUser userWithLogin: theUID roles: nil]; + person = [iCalPerson elementWithTag: @"attendee"]; + [person setCn: [user cn]]; + [person setEmail: [[user allEmails] objectAtIndex: 0]]; + [person setParticipationStatus: iCalPersonPartStatDeclined]; + [person setRsvp: @"TRUE"]; + [person setRole: @"REQ-PARTICIPANT"]; + + ownerEventObject = [self _lookupEvent: [theEvent uid] forUID: theOwner]; + theEvent = [[[theEvent parent] events] objectAtIndex: 0]; + attendees = [theEvent attendees]; + found = NO; + + // We check if the attendee that was added to a single occurence is + // present in the master component. If not, we add it with a participation + // status set to "DECLINED" + for (i = 0; i < [attendees count]; i++) + { + if ([[attendees objectAtIndex: i] hasSameEmailAddress: person]) + { + found = YES; + break; + } + } + + if (!found) + { + [theEvent addToAttendees: person]; + iCalString = [[theEvent parent] versitString]; + [ownerEventObject saveContentString: iCalString]; + } + } + else + { + iCalString = [[theEvent parent] versitString]; + } + [object saveContentString: iCalString]; } }