diff options
Diffstat (limited to 'bucky/app/bucky.js')
| -rw-r--r-- | bucky/app/bucky.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 03a8b87..86982f8 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -67,17 +67,20 @@ var bucky = (module.exports = { }); }, ensureHootstream: function (req, res, next) { + const query = { + thread: parseInt(req.query?.thread) || null, + keyword: req.query?.keyword || null, + username: req.query?.username || null, + limit: req.query?.limit || 20, + offset: req.query?.offset || 0, + }; + query.has_query = query.thread || query.keyword || query.username; Promise.all([ - db.getHootstreamFiles({ - limit: req.query.limit || 20, - offset: req.query.offset || 0, - }), - db.getHootstreamComments({ - limit: req.query.limit || 20, - offset: req.query.offset || 0, - }), + db.getHootstreamFiles(query), + db.getHootstreamComments(query), ]).then(([files, comments]) => { db.getHootstreamThreads({ files, comments }).then((threads) => { + res.query = query; res.files = files; res.comments = comments.map((comment) => { comment.comment = comment.comment.toString(); |
