summaryrefslogtreecommitdiff
path: root/bucky/app/bucky.js
diff options
context:
space:
mode:
authorjulian laplace <julescarbon@gmail.com>2022-10-26 17:05:14 +0200
committerjulian laplace <julescarbon@gmail.com>2022-10-26 17:05:14 +0200
commitdd72ab05da17309fd5ee6005cdc1fae686b5fa9e (patch)
tree9edc695fffa73a85d94e571f44c7d4c97de71654 /bucky/app/bucky.js
parent3de2a5872fd0481568e918a1ea798b3f75ace610 (diff)
filter by keyword, thread, or username
Diffstat (limited to 'bucky/app/bucky.js')
-rw-r--r--bucky/app/bucky.js19
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();