mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:57:08 +00:00
34 lines
697 B
JavaScript
34 lines
697 B
JavaScript
|
|
const { event } = require('../../../lib/db');
|
|
|
|
module.exports = async function (req, res, next) {
|
|
|
|
try {
|
|
const payload = Object.assign({}, req.body);
|
|
|
|
if (req.params.type && req.params.id) {
|
|
payload.type = req.params.type;
|
|
payload.id = req.params.id;
|
|
}
|
|
|
|
if (req.params.labels) {
|
|
payload.labels = req.params.labels.split(";");
|
|
}
|
|
|
|
if (!req.meta.isLabel) {
|
|
// User is requesting that we delete the whole event,
|
|
// not just labels
|
|
// FIXME NOTE Removal of labels would be best done via
|
|
// a PUT request.
|
|
delete payload.labels
|
|
}
|
|
|
|
await event.del(req.params.project, payload, req.query);
|
|
res.status(204).send();
|
|
next();
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
|
|
};
|