diff options
Diffstat (limited to 'bucky/app/bucky.js')
| -rw-r--r-- | bucky/app/bucky.js | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 8b829da..e7455ad 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -94,7 +94,7 @@ var bucky = module.exports = { next() }) }, - + /* DETAILS */ ensureThread: function (req, res, next){ @@ -112,6 +112,24 @@ var bucky = module.exports = { } }) }, + ensureCommentThread: function (req, res, next){ + if (! res.comment) { + return res.sendStatus(404) + } + var id = res.comment.get('thread') + if (! id) { + return res.sendStatus(404) + } + db.getThread(id).then(function(thread){ + if (thread) { + res.thread = thread + next() + } + else { + res.sendStatus(404) + } + }) + }, ensureKeywordForThread: function (req, res, next){ var keyword = res.thread.get('keyword') if (! keyword) return next() @@ -132,7 +150,16 @@ var bucky = module.exports = { next() }) }, - + bumpViewCount: function(req, res, next) { + res.thread.set('viewed', res.thread.get('viewed') + 1) + res.thread.save().then( () => next() ) + }, + bumpThreadRevisions: function (req, res, next){ + res.thread.set('revision', res.thread.get('revision')+1) + res.thread.set('lastmodified', util.now()) + res.thread.save().then( () => next() ) + }, + /* KEYWORDS */ ensureKeyword: function (req, res, next){ |
