From 7c7df9b47c791cd930702390ab2c51fa1c549f88 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 22 Oct 2021 14:32:37 -0400 Subject: [PATCH] fix(mail(web)): improve identification of mailboxes --- SoObjects/Mailer/SOGoMailAccount.m | 19 +++++++++++++++++-- .../js/Mailer/Mailbox.service.js | 19 +++++++++++++++++++ .../js/Mailer/MailboxesController.js | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index 494cebe8a..a474e1a64 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -447,7 +447,7 @@ static NSString *inboxFolderName = @"INBOX"; flags: (NSMutableArray *) flags { static NSDictionary *metadata = nil; - NSString *folderType, *key; + NSString *folderType, *key, *rights; SOGoUserDefaults *ud; if (!metadata) @@ -484,7 +484,22 @@ static NSString *inboxFolderName = @"INBOX"; else if ([folderName isEqualToString: sharedFoldersName]) folderType = @"shared"; else - folderType = @"folder"; + { + folderType = @"folder"; + if (([sharedFoldersName length] && [folderName hasPrefix: sharedFoldersName]) || + ([otherUsersFolderName length] && [folderName hasPrefix: otherUsersFolderName])) + { + rights = [[self imap4Connection] myRightsForMailboxAtURL: [NSURL URLWithString: folderName]]; + if (![rights isKindOfClass: [NSException class]] && + ([rights rangeOfString: @"r"].location == NSNotFound)) + { + [flags addObjectUniquely: @"noselect"]; + if ([rights rangeOfString: @"i"].location != NSNotFound) + // No read but insert = dropbox + folderType = @"dropbox"; + } + } + } return folderType; } diff --git a/UI/WebServerResources/js/Mailer/Mailbox.service.js b/UI/WebServerResources/js/Mailer/Mailbox.service.js index 26306d5a0..c29cecfea 100644 --- a/UI/WebServerResources/js/Mailer/Mailbox.service.js +++ b/UI/WebServerResources/js/Mailer/Mailbox.service.js @@ -204,8 +204,17 @@ this.$icon = 'thumb_down'; } else if (this.type == 'additional') { + this.$icon = 'folder'; + } + else if (this.type == 'shared') { this.$icon = 'folder_shared'; } + else if (this.type == 'otherUsers') { + this.$icon = 'folder_shared'; + } + else if (this.type == 'dropbox') { + this.$icon = 'drive_folder_upload'; + } else { this.$isSpecial = false; this.$icon = 'folder'; @@ -514,6 +523,16 @@ return this.flags.indexOf('noselect') >= 0; }; + /** + * @function isWritable + * @memberof Mailbox.prototype + * @desc Checks the user can write to the mailbox + * @returns true if messages can be inserted + */ + Mailbox.prototype.isWritable = function() { + return this.flags.indexOf('noselect') < 0 || this.type == 'dropbox'; + }; + /** * @function getClassName * @memberof Mailbox.prototype diff --git a/UI/WebServerResources/js/Mailer/MailboxesController.js b/UI/WebServerResources/js/Mailer/MailboxesController.js index dc934252a..858e69c27 100644 --- a/UI/WebServerResources/js/Mailer/MailboxesController.js +++ b/UI/WebServerResources/js/Mailer/MailboxesController.js @@ -271,7 +271,7 @@ }; // delegate this.isDroppableFolder = function(srcFolder, dstFolder) { - return (dstFolder.id != srcFolder.id) && !dstFolder.isNoSelect(); + return (dstFolder.id != srcFolder.id) && dstFolder.isWritable(); }; this.dragSelectedMessages = function(srcFolder, dstFolder, mode) {