Add logic to set mailbox aliases
This commit is contained in:
@@ -91,15 +91,27 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
submit: function (user) {
|
||||
user.busy = true;
|
||||
|
||||
var func = user.mailboxEnabled ? Client.enableUserMailbox : Client.disableUserMailbox;
|
||||
func($scope.selectedDomain.domain, user.id, function (error) {
|
||||
if (error) console.error(error);
|
||||
var aliases = user.aliases.split(',').map(function (a) { return a.trim(); }).filter(function (a) { return !!a; });
|
||||
|
||||
function done(error) {
|
||||
user.busy = false;
|
||||
|
||||
if (error) {
|
||||
console.error('Unable to configure mailbox.', error);
|
||||
return;
|
||||
}
|
||||
|
||||
// reset the dirty state
|
||||
user.orig.mailboxEnabled = user.mailboxEnabled;
|
||||
user.orig.aliases = user.aliases;
|
||||
}
|
||||
|
||||
user.busy = false;
|
||||
var func = user.mailboxEnabled ? Client.enableUserMailbox : Client.disableUserMailbox;
|
||||
func($scope.selectedDomain.domain, user.id, function (error) {
|
||||
if (error) return done(error);
|
||||
|
||||
if (user.mailboxEnabled) Client.setAliases($scope.selectedDomain.domain, user.id, aliases, done);
|
||||
else done();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -304,16 +316,20 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
Client.getMailboxes($scope.selectedDomain.domain, function (error, mailboxes) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
var enabledUsers = mailboxes.map(function (m) { return m.name; });
|
||||
$scope.mailboxes.users = $scope.users.filter(function (u) { return !!u.username; }).map(function (u) {
|
||||
u.mailboxEnabled = (enabledUsers.indexOf(u.username) !== -1);
|
||||
u.aliases = 'well, hello, there';
|
||||
Client.listAliases($scope.selectedDomain.domain, function (error, aliases) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
u.orig = {};
|
||||
u.orig.mailboxEnabled = u.mailboxEnabled;
|
||||
u.orig.aliases = u.aliases;
|
||||
var enabledUsers = mailboxes.map(function (m) { return m.name; });
|
||||
$scope.mailboxes.users = $scope.users.filter(function (u) { return !!u.username; }).map(function (u) {
|
||||
u.mailboxEnabled = (enabledUsers.indexOf(u.username) !== -1);
|
||||
u.aliases = aliases.filter(function (a) { return a.ownerId === u.id; }).map(function (a) { return a.name; }).join(',');
|
||||
|
||||
return u;
|
||||
u.orig = {};
|
||||
u.orig.mailboxEnabled = u.mailboxEnabled;
|
||||
u.orig.aliases = u.aliases;
|
||||
|
||||
return u;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user