make turn service optional

part of #810
This commit is contained in:
Girish Ramakrishnan
2023-07-13 15:06:07 +05:30
parent a2c53df042
commit 519b258a25
8 changed files with 141 additions and 5 deletions

View File

@@ -24,6 +24,7 @@ exports = module.exports = {
setLabel,
setTags,
setIcon,
setTurn,
setMemoryLimit,
setCpuShares,
setAutomaticBackup,
@@ -176,6 +177,8 @@ async function install(req, res, next) {
if ('skipDnsSetup' in data && typeof data.skipDnsSetup !== 'boolean') return next(new HttpError(400, 'skipDnsSetup must be boolean'));
if ('enableMailbox' in data && typeof data.enableMailbox !== 'boolean') return next(new HttpError(400, 'enableMailbox must be boolean'));
if ('enableTurn' in data && typeof data.enableTurn !== 'boolean') return next(new HttpError(400, 'enableTurn must be boolean'));
let [error, result] = await safe(apps.downloadManifest(data.appStoreId, data.manifest));
if (error) return next(BoxError.toHttpError(error));
@@ -407,6 +410,18 @@ async function setInbox(req, res, next) {
next(new HttpSuccess(202, { taskId: result.taskId }));
}
async function setTurn(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.app, 'object');
if (typeof req.body.enable !== 'boolean') return next(new HttpError(400, 'enable must be a boolean'));
const [error, result] = await safe(apps.setTurn(req.app, req.body.enable, AuditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(202, { taskId: result.taskId }));
}
async function setLocation(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.app, 'object');