Skip to content

Commit

Permalink
feat(mail): Add SOGoMailHideInlineAttachments option to hide attachme…
Browse files Browse the repository at this point in the history
…nts when inline. Fixes #5490.
  • Loading branch information
WoodySlum committed Nov 1, 2023
1 parent 277b73c commit abce5f4
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Documentation/SOGoInstallationGuide.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2481,6 +2481,10 @@ Defaults to `NO` when unset.
Defaults to `inline` when unset.
|U |SOGoMailHideInlineAttachments
|Hide inline message as attachements if set to `YES`. Default value is `NO`.
|U |SOGoMailCustomFullName
|The string to use as full name when composing an email, if
_SOGoMailCustomFromEnabled_ is set in the user's domain defaults.
Expand Down
5 changes: 4 additions & 1 deletion SoObjects/SOGo/SOGoUserDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,11 @@ extern NSString *SOGoPasswordRecoverySecondaryEmail;
- (void) setMailLabelsColors: (NSDictionary *) newValues;
- (NSDictionary *) mailLabelsColors;

- (void)setHideInlineAttachments:(BOOL)newValue;
- (BOOL)hideInlineAttachments;

/* calendar */
- (void) setCalendarCategories: (NSArray *) newValues;
- (void)setCalendarCategories : (NSArray *)newValues;
- (NSArray *) calendarCategories;

- (void) setCalendarCategoriesColors: (NSDictionary *) newValues;
Expand Down
10 changes: 10 additions & 0 deletions SoObjects/SOGo/SOGoUserDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,16 @@ - (NSDictionary *) mailLabelsColors
return [self objectForKey: @"SOGoMailLabelsColors"];
}

- (void) setHideInlineAttachments: (BOOL) newValue
{
[self setBool: newValue forKey: @"SOGoMailHideInlineAttachments"];
}

- (BOOL) hideInlineAttachments
{
return [self boolForKey: @"SOGoMailHideInlineAttachments"];
}

- (void) setSieveFilters: (NSArray *) newValue
{
[self setObject: newValue forKey: @"SOGoSieveFilters"];
Expand Down
28 changes: 20 additions & 8 deletions UI/MailPartViewers/UIxMailPartMixedViewer.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#import <NGMime/NGMimeBodyPart.h>
#import <NGMime/NGMimeMultipartBody.h>

#import <SOGo/SOGoUserDefaults.h>

#import <UI/MailerUI/WOContext+UIxMailer.h>

#import "UIxMailRenderingContext.h"
Expand Down Expand Up @@ -98,6 +100,7 @@ - (id) renderedPart
NSString *contentType;
id viewer, info;
NSArray *parts;
SOGoUserDefaults *ud;

NSUInteger i, max;

Expand All @@ -119,14 +122,23 @@ - (id) renderedPart
[self setChildInfo: [parts objectAtIndex: i]];

info = [self childInfo];
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self childPartPath]];
if ([self decodedFlatContent])
[viewer setDecodedContent: [parts objectAtIndex: i]];
[viewer setAttachmentIds: attachmentIds];

[renderedParts addObject: [viewer renderedPart]];

ud = [[[self context] activeUser] userDefaults];

if (!([info objectForKey:@"disposition"]
&& [[info objectForKey:@"disposition"] objectForKey:@"type"]
&& [[[info objectForKey:@"disposition"] objectForKey:@"type"] isEqualToString:@"INLINE"]
&& [ud hideInlineAttachments])) {
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self childPartPath]];
if ([self decodedFlatContent])
[viewer setDecodedContent: [parts objectAtIndex: i]];
[viewer setAttachmentIds: attachmentIds];


[renderedParts addObject: [viewer renderedPart]];
}
}

contentType = [NSString stringWithFormat: @"%@/%@",
Expand Down
1 change: 1 addition & 0 deletions UI/PreferencesUI/English.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"Insert signature on new message" = "Insert signature on new message";
"Insert signature on reply" = "Insert signature on reply";
"Insert signature on forward" = "Insert signature on forward";
"Hide inline attachments" = "Hide inline attachments";

/* Base font size for messages composed in HTML */
"Default font size" = "Default font size";
Expand Down
1 change: 1 addition & 0 deletions UI/PreferencesUI/French.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"Insert signature on new message" = "Insérer la signature sur un nouveau message";
"Insert signature on reply" = "Insérer la signature sur une réponse";
"Insert signature on forward" = "Insérer la signature sur un transfert";
"Hide inline attachments" = "Cacher les pièces jointes 'inline'";

/* Base font size for messages composed in HTML */
"Default font size" = "Taille de la police par défaut";
Expand Down
10 changes: 10 additions & 0 deletions UI/Templates/PreferencesUI/UIxPreferences.wox
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,16 @@
</md-checkbox>
</div>

<div>
<md-checkbox
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"/>
</md-checkbox>
</div>

<div>
<md-checkbox
ng-model="app.preferences.defaults.SOGoMailAutoMarkAsReadEnabled"
Expand Down

0 comments on commit abce5f4

Please sign in to comment.