2022-10-21 15:28:37 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { getService } = require('../utils');
|
2022-12-12 10:05:22 +00:00
|
|
|
const { ACTIONS } = require('../constants');
|
2022-10-21 15:28:37 +01:00
|
|
|
const validateConfig = require('./validation/admin/configureView');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
async updateViewConfiguration(ctx) {
|
|
|
|
const {
|
|
|
|
request: { body },
|
|
|
|
state: { userAbility },
|
|
|
|
} = ctx;
|
|
|
|
|
2022-12-12 10:05:22 +00:00
|
|
|
if (userAbility.cannot(ACTIONS.configureView)) {
|
2022-10-21 15:28:37 +01:00
|
|
|
return ctx.forbidden();
|
|
|
|
}
|
|
|
|
|
|
|
|
const data = await validateConfig(body);
|
|
|
|
await getService('upload').setConfiguration(data);
|
|
|
|
|
|
|
|
ctx.body = { data };
|
|
|
|
},
|
|
|
|
|
2022-11-22 11:04:45 +00:00
|
|
|
async findViewConfiguration(ctx) {
|
2022-10-21 15:28:37 +01:00
|
|
|
const data = await getService('upload').getConfiguration();
|
|
|
|
|
|
|
|
ctx.body = { data };
|
|
|
|
},
|
|
|
|
};
|