create recvmail mailbox automatically

This commit is contained in:
Girish Ramakrishnan
2018-12-06 22:31:38 -08:00
parent 7fa5ef8165
commit c507df902e
2 changed files with 10 additions and 1 deletions
+2 -1
View File
@@ -111,7 +111,8 @@
</div>
</div>
<div class="form-group" ng-show="appConfigure.app.manifest.addons.sendmail" ng-class="{ 'has-error': !appConfigureForm.mailboxName.$dirty && appConfigure.error.mailboxName }">
<!-- recvmail currently only works with cloudron email -->
<div class="form-group" ng-show="appConfigure.app.manifest.addons.sendmail || appConfigure.app.manifest.addons.recvmail" ng-class="{ 'has-error': !appConfigureForm.mailboxName.$dirty && appConfigure.error.mailboxName }">
<input type="checkbox" id="appConfigureMailboxNameEnabled" ng-model="appConfigure.mailboxNameEnabled">
<label class="control-label" for="appConfigureMailboxNameEnabled">Custom Mailbox Name</label>
<div class="has-error" ng-show="appConfigure.error.mailboxName">{{ appConfigure.error.mailboxName }}</div>
+8
View File
@@ -150,6 +150,14 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
if ($scope.appConfigure.mailboxNameEnabled) {
data.mailboxName = $scope.appConfigure.mailboxName;
// add mailbox automatically for convenience
if ($scope.appConfigure.app.manifest.addons.recvmail) {
Client.addMailbox(data.domain, data.mailboxName, $scope.user.id, function (error) {
if (error && error.statusCode !== 409) console.error(error); // it's fine if it already exists
});
}
} else { // setting to empty will reset to .app name
data.mailboxName = '';
}