diff options
Diffstat (limited to 'bucky/app/bucky.js')
| -rw-r--r-- | bucky/app/bucky.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index ab30e85..9d8d0a7 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -112,6 +112,21 @@ var bucky = module.exports = { } }) }, + prepareThread: function (req, res, next){ + var thread = res.thread + if (thread) { + var settings + try { + settings = JSON.parse(thread.get('settings') || '{}') + } catch(e) { + settings = {} + } + res.thread.set("settings", settings) + res.thread.set("display", res.thread.get("display").toString()) + res.thread.set("allowed", res.thread.get("allowed").toString()) + } + next() + }, ensureCommentThread: function (req, res, next){ if (! res.comment) { return res.sendStatus(404) @@ -135,9 +150,15 @@ var bucky = module.exports = { if (! keyword) return next() db.getKeyword(keyword).then(function(keyword){ res.keyword = keyword + if (keyword) { + keyword.set("threads", keyword.get("threads").toString()) + keyword.set("ops", keyword.get("ops").toString()) + keyword.set("display", keyword.get("display").toString()) + } next() }) }, + ensureCommentsForThread: function (req, res, next){ db.getCommentsForThread(res.thread.get('id')).then(function(comments){ res.comments = comments |
