Skip to content

Commit

Permalink
Merge pull request #268 from tfux/4911
Browse files Browse the repository at this point in the history
fix(eas): sync reminder for invitation (fixes #4911)
  • Loading branch information
extrafu committed Jan 20, 2020
2 parents 88a6755 + 9221811 commit c69382c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
12 changes: 9 additions & 3 deletions ActiveSync/SOGoActiveSyncDispatcher.m
Expand Up @@ -44,6 +44,7 @@

#import <NGCards/iCalCalendar.h>
#import <NGCards/iCalEvent.h>
#import <NGCards/iCalAlarm.h>
#import <NGCards/iCalPerson.h>

#import <NGExtensions/NGBase64Coding.h>
Expand Down Expand Up @@ -90,6 +91,7 @@
#import <Appointments/SOGoAppointmentFolder.h>
#import <Appointments/SOGoAppointmentFolders.h>
#import <Appointments/SOGoAppointmentObject.h>
#import <Appointments/iCalEntityObject+SOGo.h>

#import <Contacts/SOGoContactGCSFolder.h>
#import <Contacts/SOGoContactFolders.h>
Expand Down Expand Up @@ -1862,6 +1864,7 @@ - (void) processMeetingResponse: (id <DOMElement>) theDocumentElement
{
NSString *realCollectionId, *requestId, *easRequestId, *participationStatus, *calendarId;
SOGoAppointmentObject *appointmentObject;
iCalAlarm *alarm = nil;
SOGoMailObject *mailObject;
NSMutableDictionary *uidCache, *folderMetadata;
NSMutableString *s, *nameInCache;
Expand Down Expand Up @@ -1959,6 +1962,9 @@ - (void) processMeetingResponse: (id <DOMElement>) theDocumentElement
event = [[calendar events] lastObject];
calendarId = [event uid];

// We take the organizers's alarm to start with
alarm = [event firstSupportedAlarm];

// Fetch the SOGoAppointmentObject
collection = [[context activeUser] personalCalendarFolderInContext: context];
nameInCache = [NSString stringWithFormat: @"vevent/%@", [collection nameInContainer]];
Expand All @@ -1979,7 +1985,7 @@ - (void) processMeetingResponse: (id <DOMElement>) theDocumentElement
{
appointmentObject = [[SOGoAppointmentObject alloc] initWithName: [NSString stringWithFormat: @"%@.ics", [event uid]]
inContainer: collection];
[appointmentObject saveComponent: event force: YES];
[appointmentObject saveCalendar: [event parent]];
}

if (uidCache && [calendarId length] > 64)
Expand Down Expand Up @@ -2016,10 +2022,10 @@ - (void) processMeetingResponse: (id <DOMElement>) theDocumentElement
participationStatus = @"TENTATIVE";
else
participationStatus = @"DECLINED";

[appointmentObject changeParticipationStatus: participationStatus
withDelegate: nil
alarm: nil];
alarm: alarm];

[s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
[s appendString: @"<!DOCTYPE ActiveSync PUBLIC \"-//MICROSOFT//DTD ActiveSync//EN\" \"http://www.microsoft.com/\">"];
Expand Down
29 changes: 25 additions & 4 deletions ActiveSync/iCalEvent+ActiveSync.m
Expand Up @@ -908,8 +908,15 @@ - (void) changeParticipationStatus: (NSDictionary *) theValues
component: (id) component
{
NSString *status;
iCalAlarm *alarm;
iCalPerson *attendee;
id o;


attendee = [self userAsAttendee: [context activeUser]];
status = [attendee partStat];
alarm = nil;

// See: https://msdn.microsoft.com/en-us/library/ee202290(v=exchg.80).aspx
//
// 0 == Free
Expand All @@ -928,11 +935,25 @@ - (void) changeParticipationStatus: (NSDictionary *) theValues
else
status = @"TENTATIVE";

// There's no delegate in EAS
[(SOGoAppointmentObject *) component changeParticipationStatus: status
withDelegate: nil
alarm: nil];
}

if ((o = [theValues objectForKey: @"Reminder"]) && [o length])
{
if ([self hasAlarms])
alarm = [[self firstSupportedAlarm] mutableCopy];
else
alarm = [[iCalAlarm alloc] init];

[alarm takeActiveSyncValues: theValues inContext: context];


}

// There's no delegate in EAS
[(SOGoAppointmentObject *) component changeParticipationStatus: status
withDelegate: nil
alarm: alarm];
RELEASE(alarm);
}

@end

0 comments on commit c69382c

Please sign in to comment.