Skip to content

Commit

Permalink
(fix) handle all identities during IMIP REPLY processing
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu authored and cgx committed Jan 7, 2017
1 parent 62df4ff commit 893fdda
Showing 1 changed file with 52 additions and 23 deletions.
75 changes: 52 additions & 23 deletions UI/MailPartViewers/UIxMailPartICalViewer.m
Expand Up @@ -46,6 +46,7 @@
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserFolder.h>
#import <SOGo/SOGoUserDefaults.h>
#import <SOGo/SOGoUserManager.h>
#import <Appointments/iCalEntityObject+SOGo.h>
#import <Appointments/SOGoAppointmentFolder.h>
#import <Appointments/SOGoAppointmentObject.h>
Expand Down Expand Up @@ -457,47 +458,75 @@ - (iCalPerson *) currentUserAttendee
return currentUser;
}

- (iCalPerson *) storedReplyAttendee
- (iCalPerson *) _attendeeFromMailSenderInEvent: (iCalEvent *) e
{
NSString *baseEmail;
iCalPerson *p;

baseEmail = [self replySenderBaseEMail];

/*
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;
p = [e findAttendeeWithEmail: baseEmail];
if (!p)
p = [e findAttendeeWithEmail:[self replySenderEMail]];

p = nil;

e = [self storedEvent];
if (e)
// We haven't found it yet, let's look in the identities
// associated to this user
if (!p)
{
p = [e findAttendeeWithEmail: [self replySenderBaseEMail]];
if (!p)
p = [e findAttendeeWithEmail:[self replySenderEMail]];
SOGoUserManager *sm;
NSString *uid;

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;
}

- (iCalPerson *) storedReplyAttendee
{
iCalEvent *e;

e = [self storedEvent];
if (e)
return [self _attendeeFromMailSenderInEvent: e];

return nil;
}

- (BOOL) isReplySenderAnAttendee
{
return ([self storedReplyAttendee] != nil);
}

- (iCalPerson *) _emailParticipantWithEvent: (iCalEvent *) event
{
NSString *emailFrom;
SOGoMailObject *mailObject;
NGImap4EnvelopeAddress *address;

mailObject = [[self clientObject] mailObject];
address = [[mailObject fromEnvelopeAddresses] objectAtIndex: 0];
emailFrom = [address baseEMail];

return [event findAttendeeWithEmail: emailFrom];
return [self _attendeeFromMailSenderInEvent: event];
}

- (BOOL) hasSenderStatusChanged
Expand Down

0 comments on commit 893fdda

Please sign in to comment.