aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 5f873e2..a7b05aa 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -452,6 +452,7 @@ Serve.prototype.path = function (url) {
switch (m[1]) {
case '/new': return this.new(m[2])
case '/public': return this.public(m[2])
+ case '/threads': return this.threads(m[2])
case '/private': return this.private(m[2])
case '/mentions': return this.mentions(m[2])
case '/search': return this.search(m[2])
@@ -529,6 +530,31 @@ Serve.prototype.public = function (ext) {
)
}
+Serve.prototype.threads = function (ext) {
+ var q = this.query
+ var opts = {
+ reverse: !q.forwards,
+ sortByTimestamp: q.sort === 'claimed',
+ lt: Number(q.lt) || Date.now(),
+ gt: Number(q.gt) || -Infinity,
+ filter: q.filter,
+ }
+
+ pull(
+ this.app.createLogStream(opts),
+ pull.filter(msg => {
+ return msg.value.content.type === 'post' && !msg.value.content.root
+ }),
+ this.renderThreadPaginated(opts, null, q),
+ this.wrapMessages(),
+ this.wrapPublic(),
+ this.wrapPage('threads'),
+ this.respondSink(200, {
+ 'Content-Type': ctype(ext)
+ })
+ )
+}
+
Serve.prototype.setCookie = function (key, value, options) {
var header = key + '=' + value
if (options) for (var k in options) {