Skip to content

Commit

Permalink
fix(mail(web)): improve identification of mailboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Oct 22, 2021
1 parent 33535d3 commit 7c7df9b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
19 changes: 17 additions & 2 deletions SoObjects/Mailer/SOGoMailAccount.m
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ - (NSString *) _folderType: (NSString *) folderName
flags: (NSMutableArray *) flags
{
static NSDictionary *metadata = nil;
NSString *folderType, *key;
NSString *folderType, *key, *rights;
SOGoUserDefaults *ud;

if (!metadata)
Expand Down Expand Up @@ -484,7 +484,22 @@ - (NSString *) _folderType: (NSString *) folderName
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;
}
Expand Down
19 changes: 19 additions & 0 deletions UI/WebServerResources/js/Mailer/Mailbox.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion UI/WebServerResources/js/Mailer/MailboxesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7c7df9b

Please sign in to comment.