fix(mail(web)): improve identification of mailboxes

This commit is contained in:
Francis Lachapelle
2021-10-22 14:32:37 -04:00
parent 33535d3d79
commit 7c7df9b47c
3 changed files with 37 additions and 3 deletions
+17 -2
View File
@@ -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;
}
@@ -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
@@ -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) {