summaryrefslogtreecommitdiff
path: root/bucky/search/middleware.js
diff options
context:
space:
mode:
Diffstat (limited to 'bucky/search/middleware.js')
-rw-r--r--bucky/search/middleware.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/bucky/search/middleware.js b/bucky/search/middleware.js
index b9487b1..39d7a71 100644
--- a/bucky/search/middleware.js
+++ b/bucky/search/middleware.js
@@ -7,16 +7,29 @@ module.exports = {
search: function (req, res, next) {
res.search = search.search(req.query.query, req.query.start, req.query.limit)
console.log(res.search)
-
next()
},
+ getThreads: function (req, res, next){
+ var thread_ids = res.search.thread_ids;
+ if (! thread_ids || ! thread_ids.length) {
+ return next()
+ }
+ db.getThreadsById(thread_ids).then(function(threads){
+ res.search.threads = threads
+ next()
+ })
+ },
+
getComments: function (req, res, next){
var comment_ids = res.search.comment_ids;
if (! comment_ids || ! comment_ids.length) {
return next()
}
db.getCommentsById(comment_ids).then(function(comments){
+ comments.forEach(function(comment){
+ comment.set('comment', comment.get('comment').toString())
+ })
res.search.comments = comments
next()
})