move unarchive to apps model
This commit is contained in:
31
src/apps.js
31
src/apps.js
@@ -21,6 +21,7 @@ exports = module.exports = {
|
||||
|
||||
// user actions
|
||||
install,
|
||||
unarchive,
|
||||
uninstall,
|
||||
archive,
|
||||
|
||||
@@ -2468,6 +2469,36 @@ async function clone(app, data, user, auditSource) {
|
||||
return { id: newAppId, taskId };
|
||||
}
|
||||
|
||||
async function unarchive(archive, data, auditSource) {
|
||||
assert.strictEqual(typeof archive, 'object');
|
||||
assert.strictEqual(typeof data, 'object');
|
||||
assert(auditSource && typeof auditSource === 'object');
|
||||
|
||||
const appConfig = archive.appConfig;
|
||||
|
||||
const dolly = _.pick(appConfig, 'appStoreId', 'manifest', 'memoryLimit', 'cpuQuota', 'crontab', 'reverseProxyConfig', 'env', 'servicesConfig',
|
||||
'tags', 'label', 'enableMailbox', 'mailboxDisplayName', 'mailboxName', 'mailboxDomain', 'enableInbox', 'inboxName', 'inboxDomain', 'devices',
|
||||
'enableTurn', 'enableRedis', 'mounts', 'enableBackup', 'enableAutomaticUpdate', 'accessRestriction', 'operators', 'sso',
|
||||
'notes', 'checklist');
|
||||
|
||||
// intentionally not filled up: redirectDomain, aliasDomains, mailboxDomain
|
||||
const newAppData = Object.assign(dolly, {
|
||||
// from request
|
||||
subdomain: data.subdomain,
|
||||
domain: data.domain,
|
||||
secondaryDomains: data.secondaryDomains || {},
|
||||
ports: data.ports || null,
|
||||
overwriteDns: 'overwriteDns' in data ? data.overwriteDns : false,
|
||||
mailboxDomain: data.domain, // archive's mailboxDomain may not exist
|
||||
|
||||
// from the archive
|
||||
icon: archive.icon,
|
||||
backupId: archive.backupId,
|
||||
});
|
||||
|
||||
return await install(newAppData, auditSource);
|
||||
}
|
||||
|
||||
async function uninstall(app, auditSource) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
Reference in New Issue
Block a user