Reconfigure email apps when email is enabled/disabled

This commit is contained in:
Girish Ramakrishnan
2018-08-12 13:13:52 -07:00
parent 4dacf7064f
commit 31a62313bb
2 changed files with 22 additions and 2 deletions

View File

@@ -206,6 +206,8 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
Client.enableMailForDomain($scope.selectedDomain.domain, true , function (error) {
if (error) return console.error(error);
$scope.reconfigureEmailApps();
Client.setDnsRecords($scope.selectedDomain.domain, function (error) {
if (error) return console.error(error);
@@ -223,6 +225,8 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
Client.enableMailForDomain($scope.selectedDomain.domain, false , function (error) {
if (error) return console.error(error);
$scope.reconfigureEmailApps();
$scope.refreshDomain();
$scope.incomingEmail.busy = false;
});
@@ -525,6 +529,18 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
$location.path('/email/' + $scope.selectedDomain.domain, false);
};
// this is required because we need to rewrite the MAIL_DOMAINS env var
$scope.reconfigureEmailApps = function () {
var installedApps = Client.getInstalledApps();
for (var i = 0; i < installedApps.length; i++) {
if (!installedApps[i].manifest.addons.email) continue;
Client.configureApp(installedApps[i].id, { }, function (error) {
if (error) console.error(error);
});
}
};
$scope.refreshDomain = function () {
$scope.refreshBusy = true;