hasMailAddon is really just sendmail
This commit is contained in:
31
src/apps.js
31
src/apps.js
@@ -1156,23 +1156,17 @@ async function validateLocations(locations) {
|
||||
return domainObjectMap;
|
||||
}
|
||||
|
||||
function hasMailAddon(manifest) {
|
||||
return manifest.addons.sendmail || manifest.addons.recvmail;
|
||||
}
|
||||
|
||||
async function install(data, auditSource) {
|
||||
assert(data && typeof data === 'object');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
assert.strictEqual(typeof data.manifest, 'object'); // manifest is already downloaded
|
||||
|
||||
let location = data.location.toLowerCase(),
|
||||
const location = data.location.toLowerCase(),
|
||||
domain = data.domain.toLowerCase(),
|
||||
portBindings = data.portBindings || null,
|
||||
accessRestriction = data.accessRestriction || null,
|
||||
icon = data.icon || null,
|
||||
memoryLimit = data.memoryLimit || 0,
|
||||
sso = 'sso' in data ? data.sso : null,
|
||||
debugMode = data.debugMode || null,
|
||||
enableBackup = 'enableBackup' in data ? data.enableBackup : true,
|
||||
enableAutomaticUpdate = 'enableAutomaticUpdate' in data ? data.enableAutomaticUpdate : true,
|
||||
@@ -1211,6 +1205,7 @@ async function install(data, auditSource) {
|
||||
error = validateTags(tags);
|
||||
if (error) throw error;
|
||||
|
||||
let sso = 'sso' in data ? data.sso : null;
|
||||
if ('sso' in data && !('optionalSso' in manifest)) throw new BoxError(BoxError.BAD_FIELD, 'sso can only be specified for apps with optionalSso');
|
||||
// if sso was unspecified, enable it by default if possible
|
||||
if (sso === null) sso = !!manifest.addons['ldap'] || !!manifest.addons['proxyAuth'];
|
||||
@@ -1220,10 +1215,11 @@ async function install(data, auditSource) {
|
||||
|
||||
if (settings.isDemo() && constants.DEMO_BLACKLISTED_APPS.includes(appStoreId)) throw new BoxError(BoxError.BAD_FIELD, 'This app is blacklisted in the demo');
|
||||
|
||||
const mailboxName = hasMailAddon(manifest) ? mailboxNameForLocation(location, manifest) : null;
|
||||
const mailboxDomain = hasMailAddon(manifest) ? domain : null;
|
||||
const appId = uuid.v4();
|
||||
// sendmail is enabled by default
|
||||
const mailboxName = manifest.addons?.sendmail ? mailboxNameForLocation(location, manifest) : null;
|
||||
const mailboxDomain = manifest.addons?.sendmail ? domain : null;
|
||||
|
||||
let icon = data.icon || null;
|
||||
if (icon) {
|
||||
if (!validator.isBase64(icon)) throw new BoxError(BoxError.BAD_FIELD, 'icon is not base64', { field: 'icon' });
|
||||
icon = Buffer.from(icon, 'base64');
|
||||
@@ -1235,6 +1231,7 @@ async function install(data, auditSource) {
|
||||
|
||||
const domainObjectMap = await validateLocations(locations);
|
||||
|
||||
const appId = uuid.v4();
|
||||
debug('Will install app with id : ' + appId);
|
||||
|
||||
const app = {
|
||||
@@ -1490,7 +1487,7 @@ async function setMailbox(app, data, auditSource) {
|
||||
let error = checkAppState(app, exports.ISTATE_PENDING_RECREATE_CONTAINER);
|
||||
if (error) throw error;
|
||||
|
||||
if (!hasMailAddon(app.manifest)) throw new BoxError(BoxError.BAD_FIELD, 'App does not use mail addons');
|
||||
if (!app.manifest.addons?.sendmail) throw new BoxError(BoxError.BAD_FIELD, 'App does not use mail addons');
|
||||
|
||||
await mail.getDomain(mailboxDomain); // check if domain exists
|
||||
|
||||
@@ -1597,8 +1594,8 @@ async function setLocation(app, data, auditSource) {
|
||||
values.portBindings = translatePortBindings(data.portBindings || null, app.manifest);
|
||||
}
|
||||
|
||||
// move the mailbox name to match the new location
|
||||
if (hasMailAddon(app.manifest) && app.mailboxName.endsWith('.app')) {
|
||||
// rename the auto-created mailbox to match the new location
|
||||
if (app.manifest.addons?.sendmail && app.mailboxName.endsWith('.app')) {
|
||||
values.mailboxName = mailboxNameForLocation(values.location, app.manifest);
|
||||
values.mailboxDomain = values.domain;
|
||||
}
|
||||
@@ -1717,7 +1714,7 @@ async function updateApp(app, data, auditSource) {
|
||||
updateConfig.memoryLimit = updateConfig.manifest.memoryLimit;
|
||||
}
|
||||
|
||||
if (!hasMailAddon(manifest)) { // clear if the update removed addon
|
||||
if (!app.manifest.addons?.sendmail) { // clear if the update removed addon
|
||||
values.mailboxName = values.mailboxDomain = null;
|
||||
} else if (!app.mailboxName || app.mailboxName.endsWith('.app')) { // allocate since restore added the addon
|
||||
values.mailboxName = mailboxNameForLocation(app.location, manifest);
|
||||
@@ -1875,7 +1872,7 @@ async function restore(app, backupId, auditSource) {
|
||||
if (error) throw error;
|
||||
|
||||
let values = { manifest: backupInfo.manifest };
|
||||
if (!hasMailAddon(backupInfo.manifest)) { // clear if restore removed addon
|
||||
if (!backupInfo.manifest.addons?.sendmail) { // clear if restore removed addon
|
||||
values.mailboxName = values.mailboxDomain = null;
|
||||
} else if (!app.mailboxName || app.mailboxName.endsWith('.app')) { // allocate since restore added the addon
|
||||
values.mailboxName = mailboxNameForLocation(app.location, backupInfo.manifest);
|
||||
@@ -2033,8 +2030,8 @@ async function clone(app, data, user, auditSource) {
|
||||
if (error) throw error;
|
||||
|
||||
// should we copy the original app's mailbox settings instead?
|
||||
let mailboxName = hasMailAddon(manifest) ? mailboxNameForLocation(location, manifest) : null;
|
||||
let mailboxDomain = hasMailAddon(manifest) ? domain : null;
|
||||
const mailboxName = manifest.addons?.sendmail ? mailboxNameForLocation(location, manifest) : null;
|
||||
const mailboxDomain = manifest.addons?.sendmail ? domain : null;
|
||||
|
||||
const newAppId = uuid.v4();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user