From 1d38c91fbc8aed5b909c0ce9f60014b219fe792a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 12 Dec 2017 19:08:52 +0100 Subject: delete and reply --- bucky/app/bucky.js | 3 +++ bucky/app/router.js | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'bucky/app') diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 5fb58bf..47ad187 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -530,4 +530,7 @@ var bucky = module.exports = { next() }) }, + destroyMessage: function(req, res, next) { + res.message.destroy().then( () => next() ) + }, } \ No newline at end of file diff --git a/bucky/app/router.js b/bucky/app/router.js index 56e1f36..7fbf479 100644 --- a/bucky/app/router.js +++ b/bucky/app/router.js @@ -301,8 +301,14 @@ module.exports = function(app){ bucky.deleteDraft, function(req, res){ res.json({ status: "ok" }) - } - ) + }) + app.delete("/api/message/:id", + middleware.ensureAuthenticated, + bucky.ensureMessage, + bucky.destroyMessage, + function(req, res){ + res.json({ status: "ok" }) + }) auth.route(app) } -- cgit v1.2.3-70-g09d2