fix(mail): add support for messages quota

Fixes #5365
feature/ms-tnef
Francis Lachapelle 2021-08-04 10:02:39 -04:00
parent 510eb97860
commit a1273f1097
3 changed files with 29 additions and 8 deletions

View File

@ -289,11 +289,24 @@ static NSString *inboxFolderName = @"INBOX";
if (quota != 0 && inboxQuota != nil)
{
// A soft quota ratio is imposed for all users
quota = quota * [(NSNumber*)[inboxQuota objectForKey: @"maxQuota"] intValue];
inboxQuota = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithLong: (long)(quota+0.5)], @"maxQuota",
[NSNumber numberWithLong: [[inboxQuota objectForKey: @"usedSpace"] longLongValue]], @"usedSpace",
nil];
if ([[inboxQuota allKeys] containsObject: @"maxQuota"])
{
// Storage quota
quota = quota * [(NSNumber*)[inboxQuota objectForKey: @"maxQuota"] intValue];
inboxQuota = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithLong: (long)(quota+0.5)], @"maxQuota",
[NSNumber numberWithLong: [[inboxQuota objectForKey: @"usedSpace"] longLongValue]], @"usedSpace",
nil];
}
else if ([[inboxQuota allKeys] containsObject: @"maxMessages"])
{
// Messages quota
quota = quota * [(NSNumber*)[inboxQuota objectForKey: @"maxMessages"] intValue];
inboxQuota = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithLong: (long)(quota+0.5)], @"maxMessages",
[NSNumber numberWithLong: [[inboxQuota objectForKey: @"messagesCount"] longLongValue]], @"messagesCount",
nil];
}
}
}

View File

@ -319,6 +319,7 @@
"Operation failed" = "Operation failed";
"Quota" = "Quota:";
"quotasFormat" = "%{0}% used on %{1} MB";
"messageQuotasFormat" = "%{0}% of %{1} msgs";
"Unable to move/delete folder." = "Unable to move/delete folder.";
/* Alternative operation when folder cannot be deleted */

View File

@ -439,9 +439,16 @@
Account.prototype.updateQuota = function(data) {
var percent, format, description;
percent = (Math.round(data.usedSpace * 10000 / data.maxQuota) / 100);
format = l("quotasFormat");
description = format.formatted(percent, Math.round(data.maxQuota/10.24)/100);
if (data.maxQuota) {
percent = (Math.round(data.usedSpace * 10000 / data.maxQuota) / 100);
format = l("quotasFormat");
description = format.formatted(percent, Math.round(data.maxQuota/10.24)/100);
}
else if (data.maxMessages) {
percent = (Math.round(data.messagesCount * 10000 / data.maxMessages) / 100);
format = l("messageQuotasFormat");
description = format.formatted(percent, data.maxMessages);
}
this.$quota = { percent: percent, description: description };
};