support: add route to repair apps
This commit is contained in:
+12
@@ -83,6 +83,7 @@ exports = module.exports = {
|
||||
|
||||
restoreApps,
|
||||
configureApps,
|
||||
repairApps,
|
||||
schedulePendingTasks,
|
||||
restartAppsUsingAddons,
|
||||
|
||||
@@ -2197,6 +2198,17 @@ async function repair(app, data, auditSource) {
|
||||
return { taskId };
|
||||
}
|
||||
|
||||
async function repairApps(auditSource) {
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
const apps = await list();
|
||||
|
||||
for (const app of apps) {
|
||||
if (app.installationState !== exports.ISTATE_ERROR) continue;
|
||||
await repair(app, { /* data */}, auditSource);
|
||||
}
|
||||
}
|
||||
|
||||
async function restore(app, backupId, auditSource) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof backupId, 'string');
|
||||
|
||||
+14
-1
@@ -5,11 +5,15 @@ exports = module.exports = {
|
||||
|
||||
getRemoteSupport,
|
||||
enableRemoteSupport,
|
||||
|
||||
repairApps
|
||||
};
|
||||
|
||||
const appstore = require('../appstore.js'),
|
||||
const apps = require('../apps.js'),
|
||||
appstore = require('../appstore.js'),
|
||||
assert = require('assert'),
|
||||
AuditSource = require('../auditsource.js'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
constants = require('../constants.js'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
@@ -52,3 +56,12 @@ async function getRemoteSupport(req, res, next) {
|
||||
|
||||
next(new HttpSuccess(200, { enabled }));
|
||||
}
|
||||
|
||||
async function repairApps(req, res, next) {
|
||||
assert.strictEqual(typeof req.user, 'object');
|
||||
|
||||
const [error] = await safe(apps.repairApps(AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(202, {}));
|
||||
}
|
||||
|
||||
@@ -383,6 +383,7 @@ async function initializeExpressSync() {
|
||||
router.post('/api/v1/support/ticket', json, token, authorizeOwner, routes.support.createTicket);
|
||||
router.get ('/api/v1/support/remote_support', token, authorizeOwner, routes.support.getRemoteSupport);
|
||||
router.post('/api/v1/support/remote_support', json, token, authorizeOwner, routes.support.enableRemoteSupport);
|
||||
router.post('/api/v1/support/repair_apps', json, token, authorizeOwner, routes.support.repairApps);
|
||||
|
||||
// domain routes
|
||||
router.post('/api/v1/domains', json, token, authorizeAdmin, routes.domains.add);
|
||||
|
||||
Reference in New Issue
Block a user