mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:07:08 +00:00
Implement event DELETE middleware
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
|
||||
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) {
|
||||
console.error(err);
|
||||
next(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user