move appstore urls into appstore.js

This commit is contained in:
Girish Ramakrishnan
2023-08-04 15:34:38 +05:30
parent 37ae142a16
commit fb9d8c23e1
10 changed files with 128 additions and 128 deletions

View File

@@ -75,7 +75,6 @@ exports = module.exports = {
getExec,
checkManifestConstraints,
downloadManifest,
canAutoupdateApp,
autoupdateApps,
@@ -185,7 +184,6 @@ const appstore = require('./appstore.js'),
settings = require('./settings.js'),
shell = require('./shell.js'),
storage = require('./storage.js'),
superagent = require('superagent'),
system = require('./system.js'),
tasks = require('./tasks.js'),
tgz = require('./backupformat/tgz.js'),
@@ -1141,28 +1139,6 @@ async function getTask(app) {
return await tasks.get(app.taskId);
}
async function downloadManifest(appStoreId, manifest) {
if (!appStoreId && !manifest) throw new BoxError(BoxError.BAD_FIELD, 'Neither manifest nor appStoreId provided');
if (!appStoreId) return { appStoreId: '', manifest };
const parts = appStoreId.split('@');
const url = settings.apiServerOrigin() + '/api/v1/apps/' + parts[0] + (parts[1] ? '/versions/' + parts[1] : '');
debug('downloading manifest from %s', url);
const [error, response] = await safe(superagent.get(url).timeout(30 * 1000).ok(() => true));
if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, 'Network error downloading manifest:' + error.message);
if (response.status !== 200) throw new BoxError(BoxError.NOT_FOUND, `Failed to get app info from store. status: ${response.status} text: ${response.text}`);
if (!response.body.manifest || typeof response.body.manifest !== 'object') throw new BoxError(BoxError.NOT_FOUND, `Missing manifest. Failed to get app info from store. status: ${response.status} text: ${response.text}`);
return { appStoreId: parts[0], manifest: response.body.manifest };
}
function mailboxNameForSubdomain(subdomain, manifest) {
if (subdomain) return `${subdomain}.app`;
if (manifest.title) return manifest.title.toLowerCase().replace(/[^a-zA-Z0-9]/g, '') + '.app';