fix(mail): Fix inline pdf attachement issue when Hide inline attachment option is set. Now the option hides only inline images.

This commit is contained in:
smizrahi
2024-01-17 10:06:19 +01:00
parent 7104ae6d23
commit a6fc83c35b
6 changed files with 44 additions and 11 deletions
+1 -1
View File
@@ -2507,7 +2507,7 @@ Defaults to `inline` when unset.
|Show recipients or sender full email in mailboxes if set to `YES`. Default value is `NO`.
|U |SOGoMailHideInlineAttachments
|Hide inline message as attachements if set to `YES`. Default value is `NO`.
|Hide inline images as attachements if set to `YES`. Default value is `NO`.
|U |SOGoMailCustomFullName
+16 -3
View File
@@ -31,9 +31,13 @@
#import <UI/MailerUI/WOContext+UIxMailer.h>
#import <Mailer/SOGoMailBodyPart.h>
#import "UIxMailRenderingContext.h"
#import "UIxMailPartMixedViewer.h"
@class SOGoImageMailBodyPart;
@implementation UIxMailPartMixedViewer
- (void) dealloc
@@ -101,6 +105,7 @@
id viewer, info;
NSArray *parts;
SOGoUserDefaults *ud;
BOOL displayAttachment;
NSUInteger i, max;
@@ -127,13 +132,21 @@
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self childPartPath]];
if ([self decodedFlatContent])
[viewer setDecodedContent: [parts objectAtIndex: i]];
[viewer setAttachmentIds: attachmentIds
displayAttachment:!([info objectForKey:@"disposition"]
contentType = [NSString stringWithFormat: @"%@/%@",
[info objectForKey: @"type"],
[info objectForKey: @"subtype"]];
displayAttachment = !([info objectForKey:@"disposition"]
&& [[info objectForKey:@"disposition"] objectForKey:@"type"]
&& [[[[info objectForKey:@"disposition"] objectForKey:@"type"] uppercaseString] isEqualToString:@"INLINE"]
&& [ud hideInlineAttachments])];
&& [ud hideInlineAttachments]
&& [SOGoMailBodyPart bodyPartClassForMimeType: [contentType lowercaseString] inContext: [self context]] == [SOGoImageMailBodyPart class]);
[viewer setAttachmentIds: attachmentIds
displayAttachment: displayAttachment];
[renderedParts addObject: [viewer renderedPart]];
}
+23 -3
View File
@@ -50,6 +50,7 @@
#import <Mailer/SOGoDraftsFolder.h>
#import <Mailer/SOGoMailAccount.h>
#import <Mailer/SOGoSentFolder.h>
#import <Mailer/SOGoMailBodyPart.h>
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSObject+Utilities.h>
@@ -67,6 +68,8 @@
#import "UIxMailListActions.h"
@class SOGoImageMailBodyPart;
// The maximum number of headers to prefetch when querying the UIDs list
#define headersPrefetchMaxSize 100
@@ -318,20 +321,34 @@
NSEnumerator *part;
NSDictionary *currentPart;
SOGoUserDefaults *ud;
BOOL isInline;
BOOL isInline, isImage;
NSString *contentType;
ud = [[[self context] activeUser] userDefaults];
if ([parts count] > 1)
if ([parts count] > 0)
{
part = [parts objectEnumerator];
while (!hasAttachment
&& (currentPart = [part nextObject])) {
if ([currentPart objectForKey: @"type"] && ![[[currentPart objectForKey: @"type"] uppercaseString] hasPrefix: @"MULTIPART"]) {
contentType = [NSString stringWithFormat: @"%@/%@",
[currentPart objectForKey: @"type"],
[currentPart objectForKey: @"subtype"]];
isInline = currentPart && [currentPart objectForKey:@"disposition"]
&& [[currentPart objectForKey:@"disposition"] objectForKey:@"type"]
&& [[[[currentPart objectForKey:@"disposition"] objectForKey:@"type"] uppercaseString] isEqualToString:@"INLINE"];
if (![ud hideInlineAttachments] || ([ud hideInlineAttachments] && !isInline)) {
isImage = [SOGoMailBodyPart bodyPartClassForMimeType: [contentType lowercaseString] inContext: [self context]] == [SOGoImageMailBodyPart class];
if (![ud hideInlineAttachments] || ([ud hideInlineAttachments] && !(isInline && isImage))) {
BOOL a = [currentPart objectForKey:@"disposition"] ;
BOOL b = [[[currentPart objectForKey:@"disposition"] allKeys] length] > 0 ;
BOOL c = [currentPart objectForKey:@"parameterList"] ;
BOOL d = [[currentPart objectForKey:@"parameterList"] objectForKey:@"name"];
BOOL foo = ([currentPart objectForKey:@"parameterList"]
&& [[currentPart objectForKey:@"parameterList"] objectForKey:@"name"]
);
hasAttachment = (([currentPart objectForKey:@"disposition"]
&& [[[currentPart objectForKey:@"disposition"] allKeys] length] > 0)
|| ([currentPart objectForKey:@"parameterList"]
@@ -341,6 +358,9 @@
} else if ([currentPart objectForKey:@"parts"]) {
hasAttachment = [self parseParts: [currentPart objectForKey:@"parts"] hasAttachment: hasAttachment];
}
if (hasAttachment)
break;
}
}
@@ -205,7 +205,7 @@
"Insert signature on reply" = "Insert signature on reply";
"Insert signature on forward" = "Insert signature on forward";
"Show recipients or sender full email in mailboxes" = "Show recipients or sender full email in mailboxes";
"Hide inline attachments" = "Hide inline attachments";
"Hide inline images" = "Hide inline images";
/* Base font size for messages composed in HTML */
"Default font size" = "Default font size";
@@ -205,7 +205,7 @@
"Insert signature on reply" = "Insérer la signature sur une réponse";
"Insert signature on forward" = "Insérer la signature sur un transfert";
"Show recipients or sender full email in mailboxes" = "Afficher l'email complet du destinataire ou expéditeur dans les boîtes aux lettres";
"Hide inline attachments" = "Cacher les pièces jointes 'inline'";
"Hide inline images" = "Cacher les images 'inline'";
/* Base font size for messages composed in HTML */
"Default font size" = "Taille de la police par défaut";
@@ -710,8 +710,8 @@
ng-model="app.preferences.defaults.SOGoMailHideInlineAttachments"
ng-true-value="1"
ng-false-value="0"
label:aria-label="Hide inline attachments">
<var:string label:value="Hide inline attachments"/>
label:aria-label="Hide inline images">
<var:string label:value="Hide inline images"/>
</md-checkbox>
</div>