(feat) we now "cc" delegates during invitation updates (fixes #3195)

pull/203/head
Ludovic Marcotte 2016-03-22 13:08:38 -04:00
parent 2c038d641a
commit fee310908b
2 changed files with 92 additions and 44 deletions

1
NEWS
View File

@ -8,6 +8,7 @@ New features
Enhancements Enhancements
- [web] updated Angular Material to version 1.0.6 - [web] updated Angular Material to version 1.0.6
- [web] added Lithuanan (lt) translation - thanks to Mantas Liobė - [web] added Lithuanan (lt) translation - thanks to Mantas Liobė
- [web] we now "cc" delegates during invitation updates (#3195)
Bug fixes Bug fixes
- [web] fixed missing columns in SELECT statements (PostgreSQL) - [web] fixed missing columns in SELECT statements (PostgreSQL)

View File

@ -905,12 +905,15 @@
} }
} }
#warning fix this when sendEmailUsing blabla has been cleaned up //
- (void) sendIMIPReplyForEvent: (iCalRepeatableEntityObject *) event //
from: (SOGoUser *) from //
to: (iCalPerson *) recipient - (void) _sendIMIPReplyForEvent: (iCalRepeatableEntityObject *) event
from: (SOGoUser *) from
to: (iCalPerson *) recipient
textOnly: (BOOL) textOnly
{ {
NSString *pageName, *mailDate, *email; NSString *mailDate, *email;
WOApplication *app; WOApplication *app;
iCalPerson *attendee; iCalPerson *attendee;
SOGoAptMailICalReply *p; SOGoAptMailICalReply *p;
@ -922,50 +925,58 @@
SOGoDomainDefaults *dd; SOGoDomainDefaults *dd;
dd = [from domainDefaults]; dd = [from domainDefaults];
if ([dd appointmentSendEMailNotifications] && [event isStillRelevant])
{
/* get WOApplication instance */
app = [WOApplication application];
/* create page name */ /* get WOApplication instance */
pageName = @"SOGoAptMailICalReply"; app = [WOApplication application];
/* construct message content */
p = [app pageWithName: pageName inContext: context];
[p setApt: (iCalEvent *) event];
attendee = [event userAsAttendee: from]; /* construct message content */
[p setAttendee: attendee]; p = [app pageWithName: @"SOGoAptMailICalReply" inContext: context];
[p setApt: (iCalEvent *) event];
/* construct message */ attendee = [event userAsAttendee: from];
headerMap = [NGMutableHashMap hashMapWithCapacity: 5]; [p setAttendee: attendee];
/* NOTE: multipart/alternative seems like the correct choice but /* construct message */
* unfortunately Thunderbird doesn't offer the rich content alternative headerMap = [NGMutableHashMap hashMapWithCapacity: 5];
* at all. Mail.app shows the rich content alternative _only_
* so we'll stick with multipart/mixed for the time being. /* NOTE: multipart/alternative seems like the correct choice but
*/ * unfortunately Thunderbird doesn't offer the rich content alternative
* at all. Mail.app shows the rich content alternative _only_
* so we'll stick with multipart/mixed for the time being.
*/
#warning SOPE is just plain stupid here - if you change the case of keys, it will break the encoding of fields #warning SOPE is just plain stupid here - if you change the case of keys, it will break the encoding of fields
[headerMap setObject: [attendee mailAddress] forKey: @"from"]; [headerMap setObject: [attendee mailAddress] forKey: @"from"];
[headerMap setObject: [recipient mailAddress] forKey: @"to"]; [headerMap setObject: [recipient mailAddress] forKey: @"to"];
mailDate = [[NSCalendarDate date] rfc822DateString]; mailDate = [[NSCalendarDate date] rfc822DateString];
[headerMap setObject: mailDate forKey: @"date"]; [headerMap setObject: mailDate forKey: @"date"];
[headerMap setObject: [[p getSubject] asQPSubjectString: @"UTF-8"] [headerMap setObject: [[p getSubject] asQPSubjectString: @"UTF-8"]
forKey: @"subject"]; forKey: @"subject"];
[headerMap setObject: [NSString generateMessageID] forKey: @"message-id"]; [headerMap setObject: [NSString generateMessageID] forKey: @"message-id"];
[headerMap setObject: @"1.0" forKey: @"MIME-Version"]; [headerMap setObject: @"1.0" forKey: @"MIME-Version"];
[headerMap setObject: @"multipart/mixed" forKey: @"content-type"];
[headerMap setObject: @"calendar:invitation-reply" forKey: @"x-sogo-message-type"];
msg = [NGMimeMessage messageWithHeader: headerMap];
if (textOnly)
[headerMap setObject: @"text/html" forKey: @"content-type"];
else
[headerMap setObject: @"multipart/mixed" forKey: @"content-type"];
[headerMap setObject: @"calendar:invitation-reply" forKey: @"x-sogo-message-type"];
msg = [NGMimeMessage messageWithHeader: headerMap];
/* text part */
headerMap = [NGMutableHashMap hashMapWithCapacity: 1];
[headerMap setObject: @"text/html; charset=utf-8"
forKey: @"content-type"];
bodyPart = [NGMimeBodyPart bodyPartWithHeader: headerMap];
bodyData = [[p getBody] dataUsingEncoding: NSUTF8StringEncoding];
if (textOnly)
{
[msg setBody: bodyData];
}
else
{
/* multipart body */ /* multipart body */
body = [[NGMimeMultipartBody alloc] initWithPart: msg]; body = [[NGMimeMultipartBody alloc] initWithPart: msg];
/* text part */
headerMap = [NGMutableHashMap hashMapWithCapacity: 1];
[headerMap setObject: @"text/html; charset=utf-8"
forKey: @"content-type"];
bodyPart = [NGMimeBodyPart bodyPartWithHeader: headerMap];
bodyData = [[p getBody] dataUsingEncoding: NSUTF8StringEncoding];
[bodyPart setBody: bodyData]; [bodyPart setBody: bodyData];
/* attach text part to multipart body */ /* attach text part to multipart body */
@ -977,15 +988,51 @@
/* attach multipart body to message */ /* attach multipart body to message */
[msg setBody: body]; [msg setBody: body];
[body release]; [body release];
}
/* send the damn thing */ /* send the damn thing */
email = [recipient rfc822Email]; email = [recipient rfc822Email];
[[SOGoMailer mailerWithDomainDefaults: dd] [[SOGoMailer mailerWithDomainDefaults: dd]
sendMimePart: msg sendMimePart: msg
toRecipients: [NSArray arrayWithObject: email] toRecipients: [NSArray arrayWithObject: email]
sender: [attendee rfc822Email] sender: [attendee rfc822Email]
withAuthenticator: [self authenticatorInContext: context] withAuthenticator: [self authenticatorInContext: context]
inContext: context]; inContext: context];
}
//
//
//
- (void) sendIMIPReplyForEvent: (iCalRepeatableEntityObject *) event
from: (SOGoUser *) from
to: (iCalPerson *) recipient
{
SOGoDomainDefaults *dd;
dd = [from domainDefaults];
if ([dd appointmentSendEMailNotifications] && [event isStillRelevant])
{
// We first send to the real recipient (organizer)
[self _sendIMIPReplyForEvent: event
from: from
to: recipient
textOnly: NO];
// If we have a sent-by, we send it to it also. This is useful since
// if Alice is Bob's asssitant and invites Tony, when Tony accepts/declines
// the event, Alice will also be informed about this. See #3195 for details.
if ([recipient hasSentBy])
{
iCalPerson *sentBy;
sentBy = [[[iCalPerson alloc] init] autorelease];
[sentBy setEmail: [recipient sentBy]];
[self _sendIMIPReplyForEvent: event
from: from
to: sentBy
textOnly: YES];
}
} }
} }