Skip to content

Commit

Permalink
fix(calendar): send modification notifications for tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Oct 25, 2021
1 parent c07aeef commit 1ccfa86
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 33 deletions.
3 changes: 3 additions & 0 deletions SoObjects/Appointments/English.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions SoObjects/Appointments/SOGoAptMailReceipt.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
NSArray *deletedAttendees;
NSArray *updatedAttendees;
iCalPerson *currentRecipient;
SOGoEventOperation operation;
SOGoComponentOperation operation;
NSString *calendarName;
}

- (void) setOriginator: (NSString *) newOriginator;
- (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;
Expand Down
25 changes: 22 additions & 3 deletions SoObjects/Appointments/SOGoAptMailReceipt.m
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -136,7 +137,7 @@ - (iCalPerson *) currentRecipient
return currentRecipient;
}

- (void) setOperation: (SOGoEventOperation) theOperation
- (void) setOperation: (SOGoComponentOperation) theOperation
{
operation = theOperation;
}
Expand All @@ -160,6 +161,21 @@ - (NSString *) aptSummary

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];
Expand Down Expand Up @@ -198,7 +214,7 @@ - (NSString *) _formattedUserDate: (NSCalendarDate *) date

formatter = [currentUser dateFormatterInContext: context];

if ([apt isAllDay])
if ([apt isKindOfClass: [iCalEvent class]] && [(iCalEvent *)apt isAllDay])
return [formatter formattedDate: tzDate];
else
return [NSString stringWithFormat: @"%@ - %@",
Expand All @@ -213,7 +229,10 @@ - (NSString *) aptStartDate

- (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
6 changes: 3 additions & 3 deletions SoObjects/Appointments/SOGoCalendarComponent.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions SoObjects/Appointments/SOGoCalendarComponent.m
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -1093,11 +1093,11 @@ - (void) sendResponseToOrganizer: (iCalRepeatableEntityObject *) newComponent
//
//
//
- (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;
Expand Down
24 changes: 23 additions & 1 deletion SoObjects/Appointments/SOGoTaskObject.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2006-2014-2016 Inverse inc.
Copyright (C) 2006-2014-2021 Inverse inc.
This file is part of SOGo.
Expand All @@ -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>
Expand Down Expand Up @@ -65,6 +66,14 @@ - (NSException *) saveComponent: (id) theComponent
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];
Expand Down Expand Up @@ -111,6 +120,19 @@ - (void) prepareDeleteOccurence: (iCalToDo *) occurence

}

- (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;
Expand Down
9 changes: 5 additions & 4 deletions SoObjects/SOGo/SOGoConstants.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -49,7 +47,10 @@ typedef enum
EventCreated = 0,
EventDeleted = 1,
EventUpdated = 2,
} SOGoEventOperation;
TaskCreated = 3,
TaskDeleted = 4,
TaskUpdated = 5,
} SOGoComponentOperation;

typedef enum
{
Expand Down
41 changes: 24 additions & 17 deletions UI/Templates/Appointments/SOGoAptMailReceipt.wox
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>

0 comments on commit 1ccfa86

Please sign in to comment.