2018-04-22 07:00:04 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const passport = require('../../lib/passport');
|
2018-04-29 16:13:40 +00:00
|
|
|
const sendConfigurations = require('../../models/send-configurations');
|
2018-04-22 07:00:04 +00:00
|
|
|
|
|
|
|
const router = require('../../lib/router-async').create();
|
2018-09-29 11:30:29 +00:00
|
|
|
const {castToInteger} = require('../../lib/helpers');
|
2018-04-22 07:00:04 +00:00
|
|
|
|
|
|
|
|
2018-07-31 04:34:28 +00:00
|
|
|
router.getAsync('/send-configurations-private/:sendConfigurationId', passport.loggedIn, async (req, res) => {
|
2018-09-29 11:30:29 +00:00
|
|
|
const sendConfiguration = await sendConfigurations.getById(req.context, castToInteger(req.params.sendConfigurationId), true, true);
|
2018-07-31 04:34:28 +00:00
|
|
|
sendConfiguration.hash = sendConfigurations.hash(sendConfiguration);
|
|
|
|
return res.json(sendConfiguration);
|
|
|
|
});
|
|
|
|
|
|
|
|
router.getAsync('/send-configurations-public/:sendConfigurationId', passport.loggedIn, async (req, res) => {
|
2018-09-29 11:30:29 +00:00
|
|
|
const sendConfiguration = await sendConfigurations.getById(req.context, castToInteger(req.params.sendConfigurationId), true, false);
|
2018-04-22 07:00:04 +00:00
|
|
|
sendConfiguration.hash = sendConfigurations.hash(sendConfiguration);
|
|
|
|
return res.json(sendConfiguration);
|
|
|
|
});
|
|
|
|
|
|
|
|
router.postAsync('/send-configurations', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
|
|
|
return res.json(await sendConfigurations.create(req.context, req.body));
|
|
|
|
});
|
|
|
|
|
|
|
|
router.putAsync('/send-configurations/:sendConfigurationId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
|
|
|
const sendConfiguration = req.body;
|
2018-09-29 11:30:29 +00:00
|
|
|
sendConfiguration.id = castToInteger(req.params.sendConfigurationId);
|
2018-04-22 07:00:04 +00:00
|
|
|
|
|
|
|
await sendConfigurations.updateWithConsistencyCheck(req.context, sendConfiguration);
|
|
|
|
return res.json();
|
|
|
|
});
|
|
|
|
|
|
|
|
router.deleteAsync('/send-configurations/:sendConfigurationId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
2018-09-29 11:30:29 +00:00
|
|
|
await sendConfigurations.remove(req.context, castToInteger(req.params.sendConfigurationId));
|
2018-04-22 07:00:04 +00:00
|
|
|
return res.json();
|
|
|
|
});
|
|
|
|
|
|
|
|
router.postAsync('/send-configurations-table', passport.loggedIn, async (req, res) => {
|
|
|
|
return res.json(await sendConfigurations.listDTAjax(req.context, req.body));
|
|
|
|
});
|
|
|
|
|
2019-03-26 23:41:18 +00:00
|
|
|
router.postAsync('/send-configurations-by-namespace-table/:namespaceId', passport.loggedIn, async (req, res) => {
|
|
|
|
return res.json(await sendConfigurations.listByNamespaceDTAjax(req.context, castToInteger(req.params.namespaceId), req.body));
|
2019-03-14 15:15:37 +00:00
|
|
|
});
|
|
|
|
|
2018-11-14 21:29:31 +00:00
|
|
|
router.postAsync('/send-configurations-with-send-permission-table', passport.loggedIn, async (req, res) => {
|
|
|
|
return res.json(await sendConfigurations.listWithSendPermissionDTAjax(req.context, req.body));
|
|
|
|
});
|
|
|
|
|
2018-04-22 07:00:04 +00:00
|
|
|
module.exports = router;
|