Use matching recipient address when replying

Fixes #4495
pull/229/merge
Francis Lachapelle 2018-07-09 15:49:36 -04:00
parent d6f85efa8a
commit 120f1280a4
3 changed files with 37 additions and 3 deletions

1
NEWS
View File

@ -21,6 +21,7 @@ Bug fixes
- [web] fixed renaming a folder under iOS
- [web] fixed download of exported folders under iOS
- [web] improved server-side CSS sanitizer
- [web] match recipient address when replying (#4495)
- [eas] improved alarms syncing with EAS devices (#4351)
- [eas] avoid potential cache update when breaking sync queries (#4422)
- [eas] fixed EAS search

View File

@ -931,6 +931,7 @@ static NSString *userAgent = nil;
{
BOOL fromSentMailbox;
NSString *msgID;
NSMutableArray *addresses;
NSMutableDictionary *info;
NGImap4Envelope *sourceEnvelope;
@ -948,6 +949,12 @@ static NSString *userAgent = nil;
msgID = [sourceEnvelope messageID];
if ([msgID length] > 0)
[self setInReplyTo: msgID];
addresses = [NSMutableArray array];
[self _addEMailsOfAddresses: [sourceEnvelope to] toArray: addresses];
if ([addresses count])
[info setObject: [addresses objectAtIndex: 0] forKey: @"from"];
[self setText: [sourceMail contentForReply]];
[self setHeaders: info];
[self setSourceURL: [sourceMail imap4URLString]];

View File

@ -253,11 +253,37 @@ static NSArray *infoKeys = nil;
- (NSString *) from
{
NSArray *identities;
NSEnumerator *allIdentities;
NSDictionary *identity;
NSRange r;
BOOL valid;
if (!from)
identities = [[[self clientObject] mailAccountFolder] identities];
if ([identities count])
{
identities = [[[self clientObject] mailAccountFolder] identities];
if ([identities count])
if (from)
{
allIdentities = [identities objectEnumerator];
valid = NO;
while ((identity = [allIdentities nextObject]) && !valid)
{
// from ivar must contain a valid email address surrounded by pointy brackets
r = [[from lowercaseString] rangeOfString: [NSString stringWithFormat: @"<%@>", [[identity objectForKey: @"email"] lowercaseString]]];
if (r.length > 0)
{
valid = YES;
[from release];
from = [self _emailFromIdentity: identity];
[from retain];
}
}
if (!valid)
{
[from release];
from = nil;
}
}
if (!from)
{
from = [self _emailFromIdentity: [identities objectAtIndex: 0]];
[from retain];