fix(calendar): send modification notifications for tasks

This commit is contained in:
Francis Lachapelle
2021-10-25 15:27:01 -04:00
parent c07aeeffec
commit 1ccfa865bb
8 changed files with 85 additions and 33 deletions
@@ -12,6 +12,9 @@ vtodo_class2 = "(Confidential task)";
"The event \"%{Summary}\" was created" = "The event \"%{Summary}\" was created";
"The event \"%{Summary}\" was deleted" = "The event \"%{Summary}\" was deleted";
"The event \"%{Summary}\" was updated" = "The event \"%{Summary}\" was updated";
"The task \"%{Summary}\" was created" = "The task \"%{Summary}\" was created";
"The task \"%{Summary}\" was deleted" = "The task \"%{Summary}\" was deleted";
"The task \"%{Summary}\" was updated" = "The task \"%{Summary}\" was updated";
"The following attendees(s) were notified" = "The following attendee(s) were notified";
"The following attendees(s) were added" = "The following attendee(s) were added";
"The following attendees(s) were removed" = "The following attendee(s) were removed";
+2 -2
View File
@@ -38,7 +38,7 @@
NSArray *deletedAttendees;
NSArray *updatedAttendees;
iCalPerson *currentRecipient;
SOGoEventOperation operation;
SOGoComponentOperation operation;
NSString *calendarName;
}
@@ -46,7 +46,7 @@
- (void) setAddedAttendees: (NSArray *) theAttendees;
- (void) setDeletedAttendees: (NSArray *) theAttendees;
- (void) setUpdatedAttendees: (NSArray *) theAttendees;
- (void) setOperation: (SOGoEventOperation) theOperation;
- (void) setOperation: (SOGoComponentOperation) theOperation;
- (void) setCalendarName: (NSString *) theCalendarName;
- (NSString *) aptSummary;
+22 -3
View File
@@ -31,6 +31,7 @@
#import <NGCards/iCalEvent.h>
#import <NGCards/iCalPerson.h>
#import <NGCards/iCalToDo.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSObject+Utilities.h>
@@ -136,7 +137,7 @@ static NSCharacterSet *wsSet = nil;
return currentRecipient;
}
- (void) setOperation: (SOGoEventOperation) theOperation
- (void) setOperation: (SOGoComponentOperation) theOperation
{
operation = theOperation;
}
@@ -160,6 +161,21 @@ static NSCharacterSet *wsSet = nil;
switch (operation)
{
case TaskCreated:
s = [self labelForKey: @"The task \"%{Summary}\" was created"
inContext: context];
break;
case TaskDeleted:
s = [self labelForKey: @"The task \"%{Summary}\" was deleted"
inContext: context];
break;
case TaskUpdated:
s = [self labelForKey: @"The task \"%{Summary}\" was updated"
inContext: context];
break;
case EventCreated:
s = [self labelForKey: @"The event \"%{Summary}\" was created"
inContext: context];
@@ -198,7 +214,7 @@ static NSCharacterSet *wsSet = nil;
formatter = [currentUser dateFormatterInContext: context];
if ([apt isAllDay])
if ([apt isKindOfClass: [iCalEvent class]] && [(iCalEvent *)apt isAllDay])
return [formatter formattedDate: tzDate];
else
return [NSString stringWithFormat: @"%@ - %@",
@@ -213,7 +229,10 @@ static NSCharacterSet *wsSet = nil;
- (NSString *) aptEndDate
{
return [self _formattedUserDate: [(iCalEvent *) apt endDate]];
if ([apt isKindOfClass: [iCalEvent class]])
return [self _formattedUserDate: [(iCalEvent *) apt endDate]];
else
return [self _formattedUserDate: [(iCalToDo *) apt due]];
}
@end
@@ -1,6 +1,6 @@
/* SOGoCalendarComponent.h - this file is part of SOGo
*
* Copyright (C) 2006-2014 Inverse inc.
* Copyright (C) 2006-2021 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -75,11 +75,11 @@
- (void) sendResponseToOrganizer: (iCalRepeatableEntityObject *) newComponent
from: (SOGoUser *) owner;
- (void) sendReceiptEmailForObject: (iCalRepeatableEntityObject *) object
- (void) sendReceiptEmailForObject: (iCalEntityObject *) object
addedAttendees: (NSArray *) theAddedAttendees
deletedAttendees: (NSArray *) theDeletedAttendees
updatedAttendees: (NSArray *) theUpdatedAttendees
operation: (SOGoEventOperation) theOperation;
operation: (SOGoComponentOperation) theOperation;
- (iCalPerson *) findParticipantWithUID: (NSString *) uid;
@@ -1,6 +1,6 @@
/* SOGoCalendarComponent.m - this file is part of SOGo
*
* Copyright (C) 2006-2019 Inverse inc.
* Copyright (C) 2006-2021 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1093,11 +1093,11 @@
//
//
//
- (void) sendReceiptEmailForObject: (iCalRepeatableEntityObject *) object
- (void) sendReceiptEmailForObject: (iCalEntityObject *) object
addedAttendees: (NSArray *) theAddedAttendees
deletedAttendees: (NSArray *) theDeletedAttendees
updatedAttendees: (NSArray *) theUpdatedAttendees
operation: (SOGoEventOperation) theOperation
operation: (SOGoComponentOperation) theOperation
{
NSString *calendarName, *mailDate, *mailText, *fullSenderEmail, *senderEmail, *fullRecipientEmail, *recipientEmail;
NSDictionary *senderIdentity, *recipientIdentity;
+23 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright (C) 2006-2014-2016 Inverse inc.
Copyright (C) 2006-2014-2021 Inverse inc.
This file is part of SOGo.
@@ -21,6 +21,7 @@
#import <Foundation/NSCalendarDate.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WOResponse.h>
#import <NGObjWeb/WOContext+SoObjects.h>
@@ -65,6 +66,14 @@
baseVersion: (unsigned int) newVersion
{
NSException *ex;
iCalToDo *todo;
todo = (iCalToDo*)[theComponent firstChildWithTag: [self componentTag]];
[self sendReceiptEmailForObject: todo
addedAttendees: nil
deletedAttendees: nil
updatedAttendees: nil
operation: [self isNew] ? TaskCreated : TaskUpdated];
ex = [super saveComponent: theComponent baseVersion: newVersion];
[fullCalendar release];
@@ -111,6 +120,19 @@
}
- (NSException *) prepareDelete
{
iCalToDo *todo = [self component: NO secure: NO];
[self sendReceiptEmailForObject: todo
addedAttendees: nil
deletedAttendees: nil
updatedAttendees: nil
operation: TaskDeleted];
return [super prepareDelete];
}
- (id) PUTAction: (WOContext *) _ctx
{
iCalCalendar *rqCalendar;
+5 -4
View File
@@ -1,8 +1,6 @@
/* SOGoConstants.h - this file is part of SOGo
*
* Copyright (C) 2010 Inverse inc.
*
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
* Copyright (C) 2010-2021 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -49,7 +47,10 @@ typedef enum
EventCreated = 0,
EventDeleted = 1,
EventUpdated = 2,
} SOGoEventOperation;
TaskCreated = 3,
TaskDeleted = 4,
TaskUpdated = 5,
} SOGoComponentOperation;
typedef enum
{
@@ -17,31 +17,33 @@ th, td { font-family: Lucida Grande, Bitstream VeraSans, Tahoma, sans-serif; fon
<tr>
<th></th>
<td><h1 style="font-size: 18px; font-weight: normal; padding-bottom: 9px; border-bottom: 1px solid #ccc;"><var:string
value="aptSummary" const:escapeHTML="NO"/></h1></td>
value="aptSummary"/></h1></td>
</tr>
<tr>
<th align="right" style="font-weight: bold;"><var:string label:value="calendar_label" const:escapeHTML="NO"/></th>
<td><var:string value="calendarName" const:escapeHTML="NO"/></td>
<th align="right" style="font-weight: bold;"><var:string label:value="calendar_label"/></th>
<td><var:string value="calendarName"/></td>
</tr>
<var:if condition="apt.location.length"
><tr>
<th align="right" style="font-weight: bold;"><var:string label:value="location_label" const:escapeHTML="NO"/></th>
<td><var:string value="apt.location" const:escapeHTML="NO"/></td>
<th align="right" style="font-weight: bold;"><var:string label:value="location_label"/></th>
<td><var:string value="apt.location"/></td>
</tr></var:if>
<var:if condition="aptStartDate"
><tr>
<th align="right" style="font-weight: bold;"><var:string label:value="startDate_label"/></th>
<td><var:string value="aptStartDate"/></td>
</tr></var:if>
<var:if condition="aptEndDate"
><tr>
<th align="right" style="font-weight: bold;"><var:string label:value="endDate_label"/></th>
<td><var:string value="aptEndDate"/></td>
</tr></var:if>
<tr>
<th align="right" style="font-weight: bold;"><var:string label:value="startDate_label" const:escapeHTML="NO"/></th>
<td><var:string value="aptStartDate" const:escapeHTML="NO"/></td>
</tr>
<tr>
<th align="right" style="font-weight: bold;"><var:string label:value="endDate_label" const:escapeHTML="NO"/></th>
<td><var:string value="aptEndDate" const:escapeHTML="NO"/></td>
</tr>
<var:if condition="updatedAttendees.count"
><tr>
<td></td>
<th align="left" style="font-weight: bold; padding-top: 9px;"><var:string
label:value="The following attendees(s) were notified" const:escapeHTML="NO"/></th>
label:value="The following attendees(s) were notified"/></th>
</tr>
<var:foreach list="updatedAttendees" item="currentRecipient">
<tr>
@@ -54,7 +56,7 @@ th, td { font-family: Lucida Grande, Bitstream VeraSans, Tahoma, sans-serif; fon
><tr>
<td></td>
<th align="left" style="font-weight: bold; padding-top: 9px;"><var:string
label:value="The following attendees(s) were added" const:escapeHTML="NO"/></th>
label:value="The following attendees(s) were added"/></th>
</tr>
<var:foreach list="addedAttendees" item="currentRecipient">
<tr>
@@ -67,14 +69,19 @@ th, td { font-family: Lucida Grande, Bitstream VeraSans, Tahoma, sans-serif; fon
><tr>
<td></td>
<th align="left" style="font-weight: bold; padding-top: 9px;"><var:string
label:value="The following attendees(s) were removed" const:escapeHTML="NO"/></th>
label:value="The following attendees(s) were removed"/></th>
</tr>
<var:foreach list="deletedAttendees" item="currentRecipient">
<tr>
<td></td>
<td><a var:href="currentRecipient.email"><var:string value="currentRecipient.cn" const:escapeHTML="NO"/></a></td>
<td><a var:href="currentRecipient.email"><var:string value="currentRecipient.cn"/></a></td>
</tr></var:foreach>
</var:if>
<var:if condition="apt.comment.length"
><tr>
<th align="right" style="font-weight: bold;"><var:string label:value="comment_label"/></th>
<td><var:string value="apt.comment" const:escapeHTML="NO"/></td>
</tr></var:if>
</table>
</body>
</html>