(fix) handle all identities during IMIP REPLY processing

This commit is contained in:
Ludovic Marcotte 2017-01-06 14:23:52 -05:00
parent bdd8254e02
commit 942ddcabe4

View file

@ -43,6 +43,7 @@
#import <SOGo/SOGoUser.h> #import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserFolder.h> #import <SOGo/SOGoUserFolder.h>
#import <SOGo/SOGoUserDefaults.h> #import <SOGo/SOGoUserDefaults.h>
#import <SOGo/SOGoUserManager.h>
#import <Appointments/iCalEntityObject+SOGo.h> #import <Appointments/iCalEntityObject+SOGo.h>
#import <Appointments/SOGoAppointmentFolder.h> #import <Appointments/SOGoAppointmentFolder.h>
#import <Appointments/SOGoAppointmentObject.h> #import <Appointments/SOGoAppointmentObject.h>
@ -470,31 +471,67 @@
return currentUser; return currentUser;
} }
- (iCalPerson *) storedReplyAttendee - (iCalPerson *) _attendeeFromMailSenderInEvent: (iCalEvent *) e
{ {
/* NSString *baseEmail;
TODO: since an attendee can have multiple email addresses, maybe we
should translate the email to an internal uid and then retrieve
all emails addresses for matching the participant.
Note: -findAttendeeWithEmail: does not parse the email!
*/
iCalEvent *e;
iCalPerson *p; iCalPerson *p;
p = nil; baseEmail = [self replySenderBaseEMail];
e = [self storedEvent]; /*
if (e) Note: -findAttendeeWithEmail: does not parse the email!
*/
p = [e findAttendeeWithEmail: baseEmail];
if (!p)
p = [e findAttendeeWithEmail:[self replySenderEMail]];
// We haven't found it yet, let's look in the identities
// associated to this user
if (!p)
{ {
p = [e findAttendeeWithEmail: [self replySenderBaseEMail]]; SOGoUserManager *sm;
if (!p) NSString *uid;
p = [e findAttendeeWithEmail:[self replySenderEMail]];
sm = [SOGoUserManager sharedUserManager];
uid = [sm getUIDForEmail: [self replySenderBaseEMail]];
if (uid)
{
NSArray *allEmails;
NSString *email;
SOGoUser *u;
int i;
u = [SOGoUser userWithLogin: uid];
allEmails = [u allEmails];
for (i = 0; i < [allEmails count]; i++)
{
email = [allEmails objectAtIndex: i];
if ([email caseInsensitiveCompare: baseEmail] == NSOrderedSame)
continue;
p = [e findAttendeeWithEmail: email];
if (p)
break;
}
}
} }
return p; return p;
} }
- (iCalPerson *) storedReplyAttendee
{
iCalEvent *e;
e = [self storedEvent];
if (e)
return [self _attendeeFromMailSenderInEvent: e];
return nil;
}
- (BOOL) isReplySenderAnAttendee - (BOOL) isReplySenderAnAttendee
{ {
return ([self storedReplyAttendee] != nil); return ([self storedReplyAttendee] != nil);
@ -502,15 +539,7 @@
- (iCalPerson *) _emailParticipantWithEvent: (iCalEvent *) event - (iCalPerson *) _emailParticipantWithEvent: (iCalEvent *) event
{ {
NSString *emailFrom; return [self _attendeeFromMailSenderInEvent: event];
SOGoMailObject *mailObject;
NGImap4EnvelopeAddress *address;
mailObject = [[self clientObject] mailObject];
address = [[mailObject fromEnvelopeAddresses] objectAtIndex: 0];
emailFrom = [address baseEMail];
return [event findAttendeeWithEmail: emailFrom];
} }
- (BOOL) hasSenderStatusChanged - (BOOL) hasSenderStatusChanged