aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/app.js1
-rw-r--r--lib/serve.js26
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/app.js b/lib/app.js
index c841ab0..03e3010 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -95,6 +95,7 @@ function App(sbot, config) {
this.navLinks = conf.nav || [
'new',
'public',
+ 'threads',
this.sbot.private && 'private',
'mentions',
'peers',
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) {