summaryrefslogtreecommitdiff
path: root/bucky/app/bucky.js
diff options
context:
space:
mode:
Diffstat (limited to 'bucky/app/bucky.js')
-rw-r--r--bucky/app/bucky.js25
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) => {