diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-11 10:34:34 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-11 10:34:34 +0100 |
| commit | 3aad9b4b70921e9be670560f42f00dcd448e27bb (patch) | |
| tree | e43bb3ab6ffd38492c6ca1c733c74e51443491ef /bucky/app/bucky.js | |
| parent | d56452cd8c61cf463cd1bfbb5488dfc2f7387175 (diff) | |
bumpViewCount and revisions
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){ |
