Skip to content

Commit

Permalink
fix(calendar): send notification on move and copy operations
Browse files Browse the repository at this point in the history
Fixes #3792
  • Loading branch information
cgx committed Jan 27, 2022
1 parent 2e58ddf commit aca7fc5
Showing 1 changed file with 52 additions and 11 deletions.
63 changes: 52 additions & 11 deletions SoObjects/Appointments/SOGoCalendarComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -1269,9 +1269,9 @@ - (NSArray *) getUIDsForICalPersons: (NSArray *) iCalPersons
return uids;
}

- (NSException *) _copyComponent: (iCalCalendar *) calendar
toFolder: (SOGoGCSFolder *) newFolder
updateUID: (BOOL) updateUID
- (SOGoCalendarComponent *) _copyComponent: (iCalCalendar *) calendar
toFolder: (SOGoGCSFolder *) newFolder
updateUID: (BOOL) updateUID
{
NSString *newUID;
SOGoCalendarComponent *newComponent;
Expand All @@ -1296,7 +1296,7 @@ - (NSException *) _copyComponent: (iCalCalendar *) calendar
[NSString stringWithFormat: @"%@.ics", newUID]
inContainer: newFolder];

return [newComponent saveCalendar: calendar];
return newComponent;
}

- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder
Expand All @@ -1308,21 +1308,62 @@ - (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder
- (NSException *) copyComponent: (iCalCalendar *) calendar
toFolder: (SOGoGCSFolder *) newFolder
{
return [self _copyComponent: calendar
toFolder: newFolder
updateUID: YES];
iCalEvent *event;
SOGoCalendarComponent *newComponent;
NSException *ex;

newComponent = [self _copyComponent: calendar
toFolder: newFolder
updateUID: YES];
ex = [newComponent saveCalendar: calendar];

if (!ex)
{
// Trigger notification in destination folder
event = [[calendar events] objectAtIndex: 0];
[newComponent sendReceiptEmailForObject: event
addedAttendees: nil
deletedAttendees: nil
updatedAttendees: nil
operation: EventCreated];
}

return ex;
}

- (NSException *) moveToFolder: (SOGoGCSFolder *) newFolder
{
iCalCalendar *calendar;
iCalEvent *event;
SOGoCalendarComponent *newComponent;
NSException *ex;

ex = [self _copyComponent: [self calendar: NO secure: NO]
toFolder: newFolder
updateUID: NO];
calendar = [self calendar: NO secure: NO];
newComponent = [self _copyComponent: calendar
toFolder: newFolder
updateUID: NO];
ex = [newComponent saveCalendar: calendar];

if (!ex)
ex = [self delete];
{
// Trigger notification in destination folder
event = [[calendar events] objectAtIndex: 0];
[newComponent sendReceiptEmailForObject: event
addedAttendees: nil
deletedAttendees: nil
updatedAttendees: nil
operation: EventCreated];
ex = [self delete];
if (!ex)
{
// Trigger notification in source folder
[self sendReceiptEmailForObject: event
addedAttendees: nil
deletedAttendees: nil
updatedAttendees: nil
operation: EventDeleted];
}
}

return ex;
}
Expand Down

0 comments on commit aca7fc5

Please sign in to comment.