diff --git a/src/apps.js b/src/apps.js index 239b2ac9a..b886ac8f5 100644 --- a/src/apps.js +++ b/src/apps.js @@ -648,6 +648,9 @@ function checkAppState(app, state) { if (app.taskId) return new BoxError(BoxError.BAD_STATE, `Not allowed in this app state : ${app.installationState} / ${app.runState}`); if (app.installationState === exports.ISTATE_ERROR) { + if (app.error.installationState === state) return null; + + // allow uninstall from any state if (state !== exports.ISTATE_PENDING_UNINSTALL) return new BoxError(BoxError.BAD_STATE, 'Not allowed in error state'); } diff --git a/src/routes/tasks.js b/src/routes/tasks.js index 784c777d4..49e218536 100644 --- a/src/routes/tasks.js +++ b/src/routes/tasks.js @@ -31,7 +31,7 @@ function get(req, res, next) { tasks.get(req.params.taskId, function (error, task) { if (error) return next(BoxError.toHttpError(error)); - next(new HttpSuccess(200, tasks.removePrivateFields(task))); + next(new HttpSuccess(200, task)); }); } @@ -47,8 +47,6 @@ function list(req, res, next) { tasks.listByTypePaged(req.query.type || null, page, perPage, function (error, result) { if (error) return next(BoxError.toHttpError(error)); - result = result.map(tasks.removePrivateFields); - next(new HttpSuccess(200, { tasks: result })); }); } diff --git a/src/tasks.js b/src/tasks.js index 9cf5e1151..d04859312 100644 --- a/src/tasks.js +++ b/src/tasks.js @@ -14,8 +14,6 @@ exports = module.exports = { stopTask: stopTask, stopAllTasks: stopAllTasks, - removePrivateFields: removePrivateFields, - // task types. if you add a task here, fill up the function table in taskworker TASK_APP: 'app', TASK_BACKUP: 'backup', @@ -269,9 +267,3 @@ function getLogs(taskId, options, callback) { callback(null, transformStream); } - -// removes all fields that are strictly private and should never be returned by API calls -function removePrivateFields(task) { - var result = _.pick(task, 'id', 'type', 'percent', 'message', 'error', 'active', 'creationTime', 'result', 'ts', 'success'); - return result; -}