use the new mailbox API that has aliases

part of cloudron/box#738
This commit is contained in:
Girish Ramakrishnan
2021-01-07 21:40:51 -08:00
parent f594abaa71
commit d7a2732dc6
2 changed files with 11 additions and 21 deletions

View File

@@ -471,30 +471,20 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
refresh: function (callback) {
callback = typeof callback === 'function' ? callback : function (error) { if (error) return console.error(error); };
Client.getMailboxes($scope.domain.domain, $scope.mailboxes.search, $scope.mailboxes.currentPage, $scope.mailboxes.perPage, function (error, mailboxes) {
Client.listMailboxes($scope.domain.domain, $scope.mailboxes.search, $scope.mailboxes.currentPage, $scope.mailboxes.perPage, function (error, mailboxes) {
if (error) return callback(error);
mailboxes.forEach(function (m) {
m.owner = $scope.owners.find(function (o) { return o.id === m.ownerId; }); // owner may not exist
m.ownerDisplayName = m.owner ? m.owner.display : ''; // this meta property is set when we get the user list
var u = $scope.diskUsage[m.name + '@' + m.domain]; // this is unset when no emails have been received yet
m.usage = (u && u.size) || 0;
});
$scope.mailboxes.mailboxes = mailboxes;
async.eachSeries(mailboxes, function (m, iteratorCallback) {
Client.getAliases(m.name, m.domain, function (error, aliases) {
if (error) return iteratorCallback(error);
m.aliases = aliases;
m.owner = $scope.owners.find(function (o) { return o.id === m.ownerId; }); // owner may not exist
m.ownerDisplayName = m.owner ? m.owner.display : ''; // this meta property is set when we get the user list
iteratorCallback();
});
}, function iteratorDone(error) {
if (error) return callback(error);
$scope.mailboxes.mailboxes.forEach(function (m) {
var u = $scope.diskUsage[m.name + '@' + m.domain]; // this is unset when no emails have been received yet
m.usage = (u && u.size) || 0;
});
callback();
});
callback();
});
},