Skip to content

Commit

Permalink
feat(reply): add references header when replying
Browse files Browse the repository at this point in the history
  • Loading branch information
QHivert committed Oct 4, 2023
1 parent e460e53 commit b396a27
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions SoObjects/Mailer/SOGoDraftObject.h
Expand Up @@ -56,6 +56,7 @@
int sourceIMAP4ID;
NSMutableDictionary *headers;
NSString *inReplyTo;
NSString *references;
NSString *text;
NSString *sourceURL;
NSString *sourceFlag;
Expand Down Expand Up @@ -95,6 +96,9 @@
- (NSString *) inReplyTo;
- (void) setInReplyTo: (NSString *) newInReplyTo;

- (NSString *) references;
- (void) setReferences: (NSString *) newReferences;

- (void) setSourceURL: (NSString *) newSurceURL;
- (void) setSourceFlag: (NSString *) newSourceFlag;
- (void) setSourceFolder: (NSString *) newSourceFolder;
Expand Down
29 changes: 29 additions & 0 deletions SoObjects/Mailer/SOGoDraftObject.m
Expand Up @@ -138,6 +138,7 @@ - (id) init
sourceURL = nil;
sourceFlag = nil;
inReplyTo = nil;
references = nil;
isHTML = NO;
sign = NO;
encrypt = NO;
Expand All @@ -155,6 +156,7 @@ - (void) dealloc
[sourceURL release];
[sourceFlag release];
[inReplyTo release];
[references release];
[super dealloc];
}

Expand Down Expand Up @@ -361,6 +363,16 @@ - (void) setInReplyTo: (NSString *) newInReplyTo
ASSIGN (inReplyTo, newInReplyTo);
}

- (NSString *) references
{
return references;
}

- (void) setReferences: (NSString *) newReferences
{
ASSIGN (references, newReferences);
}

- (void) setSourceURL: (NSString *) newSourceURL
{
ASSIGN (sourceURL, newSourceURL);
Expand Down Expand Up @@ -421,6 +433,8 @@ - (NSException *) storeInfo
forKey: @"isHTML"];
if (inReplyTo)
[infos setObject: inReplyTo forKey: @"inReplyTo"];
if (references)
[infos setObject: references forKey: @"references"];
if (sourceIMAP4ID > -1)
[infos setObject: [NSString stringWithFormat: @"%i", sourceIMAP4ID]
forKey: @"sourceIMAP4ID"];
Expand Down Expand Up @@ -492,6 +506,10 @@ - (void) _loadInfosFromDictionary: (NSDictionary *) infoDict
value = [infoDict objectForKey: @"inReplyTo"];
if (value)
[self setInReplyTo: value];

value = [infoDict objectForKey: @"references"];
if (value)
[self setReferences: value];
}

//
Expand Down Expand Up @@ -1041,6 +1059,7 @@ - (void) fetchMailForReplying: (SOGoMailObject *) sourceMail
{
BOOL fromSentMailbox;
NSString *msgID;
NSString *oldReferences;
NSMutableDictionary *info;
NGImap4Envelope *sourceEnvelope;
SOGoUserDefaults *ud;
Expand All @@ -1059,6 +1078,13 @@ - (void) fetchMailForReplying: (SOGoMailObject *) sourceMail
msgID = [sourceEnvelope messageID];
if ([msgID length] > 0)
[self setInReplyTo: msgID];
oldReferences = [sourceMail references];
if ([oldReferences length] > 0)
[self setReferences: [oldReferences stringByAppendingFormat: @" %@", msgID]];
else
[self setReferences: msgID];



ud = [[context activeUser] userDefaults];

Expand Down Expand Up @@ -1832,6 +1858,9 @@ - (NGMutableHashMap *) mimeHeaderMapWithHeaders: (NSDictionary *) _headers
if (inReplyTo)
[map setObject: inReplyTo forKey: @"in-reply-to"];

if (references)
[map setObject: references forKey: @"references"];

/* add subject */
if ([(s = [headers objectForKey: @"subject"]) length] > 0)
[map setObject: [s asQPSubjectString: @"utf-8"]
Expand Down
1 change: 1 addition & 0 deletions SoObjects/Mailer/SOGoMailObject.h
Expand Up @@ -97,6 +97,7 @@ extern NSArray *SOGoMailCoreInfoKeys;
- (NSString *) cc;
- (NSString *) from;
- (NSString *) inReplyTo;
- (NSString *) references;
- (NSString *) messageId;
- (NSString *) received;

Expand Down

0 comments on commit b396a27

Please sign in to comment.