applinks icon improvements

This commit is contained in:
Johannes Zellner
2022-07-08 17:47:53 +02:00
parent e800c7d282
commit 2facc6774b
2 changed files with 15 additions and 0 deletions

View File

@@ -22,6 +22,9 @@ async function listByUser(req, res, next) {
const [error, result] = await safe(applinks.listByUser(req.user));
if (error) return next(BoxError.toHttpError(error));
// we have a separate route for this
result.forEach(function (a) { delete a.icon; });
next(new HttpSuccess(200, { applinks: result }));
}
@@ -45,6 +48,9 @@ async function get(req, res, next) {
const [error, result] = await safe(applinks.get(req.params.id));
if (error) return next(BoxError.toHttpError(error));
// we have a separate route for this
delete result.icon;
next(new HttpSuccess(200, result));
}
@@ -56,6 +62,7 @@ async function update(req, res, next) {
if ('label' in req.body && typeof req.body.label !== 'string') return next(new HttpError(400, 'label must be a string'));
if ('tags' in req.body && !Array.isArray(req.body.tags)) return next(new HttpError(400, 'tags must be an array with strings'));
if ('accessRestriction' in req.body && typeof req.body.accessRestriction !== 'object') return next(new HttpError(400, 'accessRestriction must be an object'));
if ('icon' in req.body && typeof req.body.icon !== 'string') return next(new HttpError(400, 'icon must be a string'));
const [error] = await safe(applinks.update(req.params.id, req.body));
if (error) return next(BoxError.toHttpError(error));