diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-01-11 13:55:55 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-01-11 13:55:55 +0100 |
| commit | b3ba48a22ce966e62cfad1671e4ee6f4357bb69f (patch) | |
| tree | 4c670b51c4f43ebf6f857b5999c2bc0f3f0e807c /bucky/app/bucky.js | |
| parent | 2e9e542bfb81c3aff407801e3ae3f08eee0fb3d9 (diff) | |
move file api, debug flag on url to show ids
Diffstat (limited to 'bucky/app/bucky.js')
| -rw-r--r-- | bucky/app/bucky.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 84bbe70..77e1667 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -113,6 +113,21 @@ var bucky = module.exports = { } }) }, + ensureThreadById: function (req, res, next){ + var id = req.params.thread_id.replace(/\D/g, "") + if (! id) { + return res.sendStatus(404) + } + db.getThread(id).then(function(thread){ + if (thread) { + res.thread = thread + next() + } + else { + res.sendStatus(404) + } + }) + }, prepareThread: function (req, res, next){ var thread = res.thread if (thread) { @@ -380,6 +395,14 @@ var bucky = module.exports = { res.sendStatus(500) }) }, + moveComment: function(req, res, next){ + res.comment.set('thread', res.thread.get('id')) + res.comment.save().then(() => { + next() + }).catch(err => { + res.sendStatus(500) + }) + }, destroyComment: function(req, res, next){ res.comment.destroy().then(() => { next() @@ -451,6 +474,13 @@ var bucky = module.exports = { console.log(err) }) }, + moveFile: function(req, res, next){ + db.moveFile(res.file, res.thread.get('id')).then(() => { + next() + }).catch(err => { + res.sendStatus(500) + }) + }, destroyFile: function(req,res,next){ var filePromises = db.destroyFiles([res.file]) Promise.all(filePromises).then( () => next() ) |
