diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 04:41:13 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 04:41:13 +0100 |
| commit | 041efed20500c145a639d8303c2a0e770bba4552 (patch) | |
| tree | 8a8c00ac93589036b1b917a8f3e58e06670e1f33 /bucky/app/bucky.js | |
| parent | d4ece4ab1f461653c53bb56f23406c553ea78dd3 (diff) | |
hoot order!
Diffstat (limited to 'bucky/app/bucky.js')
| -rw-r--r-- | bucky/app/bucky.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 6ec76a0..41c3bff 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -158,7 +158,6 @@ var bucky = module.exports = { next() }) }, - ensureCommentsForThread: function (req, res, next){ db.getCommentsForThread(res.thread.get('id')).then(function(comments){ res.comments = comments || [] @@ -180,6 +179,30 @@ var bucky = module.exports = { res.thread.set('lastmodified', util.now()) res.thread.save().then( () => next() ) }, + updateThreadSettings: function (req, res, next){ + var title = util.sanitize(req.body.title || "") + if (! title || ! title.length) { + return res.sendStatus(500) + } + var keyword = util.sanitize(req.body.keyword || "") + var settings + if (typeof req.body.settings === 'object') { + try { + settings = JSON.stringify(req.body.settings) + } catch(e) { + } + } + if (! settings) { + return res.sendStatus(500) + } + res.thread.set('title', title) + res.thread.set('keyword', keyword) + res.thread.set('color', util.sanitize(req.body.color || 'blue')) + res.thread.set('revision', res.thread.get('revision')+1) + res.thread.set('settings', settings) + res.thread.save().then( () => next() ) + }, + destroyThread: function (req, res, next) { console.log(">>> destroying thread", res.thread.get('id')) var commentPromises = res.comments.map((comment) => { |
