aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoffle <sww@eight45.net>2020-03-04 23:13:39 -0800
committernoffle <sww@eight45.net>2020-03-04 23:13:39 -0800
commit12b3e229c3fd0d4a79c5521170f6ed855f4a6a03 (patch)
treec096b44e5c40fdeacfeeb9721014e08f9534e8b6
parent67dfa43e8df1dbf3a3238a452531c10da46325b8 (diff)
downloadpatchfoo-12b3e229c3fd0d4a79c5521170f6ed855f4a6a03.tar.gz
patchfoo-12b3e229c3fd0d4a79c5521170f6ed855f4a6a03.zip
threads navpage
-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) {