From 041efed20500c145a639d8303c2a0e770bba4552 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 12 Dec 2017 04:41:13 +0100 Subject: hoot order! --- bucky/app/bucky.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'bucky/app/bucky.js') 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) => { -- cgit v1.2.3-70-g09d2