aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js57
1 files changed, 55 insertions, 2 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 21f08ac..f7e0620 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -28,6 +28,7 @@ var Url = require('url')
var many = require('pull-many')
var merge = require('pull-merge')
var pSort = require('pull-sort')
+var channels = require("./channels-lib");
module.exports = Serve
@@ -520,7 +521,7 @@ Serve.prototype.path = function (url) {
switch (m[1]) {
case '/new': return this.new(m[2])
case '/public': return this.public(m[2])
- case '/logbook': return this.logbook(m[2])
+ case '/logbook': return this.logbook2(m[2])
case '/threads': return this.threads(m[2])
case '/private': return this.private(m[2])
case '/mentions': return this.mentions(m[2])
@@ -579,6 +580,57 @@ Serve.prototype.home = function () {
)
}
+Serve.prototype.logbook2 = function (ext) {
+ var q = this.query
+ var opts = {
+ reverse: !q.forwards,
+ //sortByTimestamp: q.sort === 'claimed',
+ sortByTimestamp: q.sort || 'claimed',
+ lt: Number(q.lt) || Date.now(),
+ gt: Number(q.gt) || -Infinity,
+ filter: q.filter,
+ }
+
+ channels.getMessages(this.app.sbot, "logbook", this, function(messageStream, serve) {
+ pull(messageStream,
+ serve.renderThreadPaginated(opts, null, q),
+ serve.wrapMessages(),
+ serve.wrapPublic(),
+ serve.wrapPage('logbook'),
+ serve.respondSink(200, {
+ 'Content-Type': ctype(ext)
+ })
+ //pull.drain(function(msg) {
+ //console.log(JSON.stringify(msg));
+ //})
+ )
+ }
+ , hops=3)
+
+ //this.renderThreadPaginated(opts, null, q),
+ //this.wrapMessages(),
+ //this.wrapPublic(),
+ //this.wrapPage('public'),
+ //this.respondSink(200, {
+ //'Content-Type': ctype(ext)
+ //})
+ //)
+ //});
+
+ //pull(
+ //this.app.createLogStream(opts),
+ //pull.filter(msg => {
+ //return !msg.value.content.vote
+ //}),
+ //this.renderThreadPaginated(opts, null, q),
+ //this.wrapMessages(),
+ //this.wrapPublic(),
+ //this.wrapPage('public'),
+ //this.respondSink(200, {
+ //'Content-Type': ctype(ext)
+ //})
+ //)
+}
compareMsgs = function(a, b) {
return -(a.value.timestamp - b.value.timestamp)
}
@@ -622,7 +674,8 @@ Serve.prototype.public = function (ext) {
var q = this.query
var opts = {
reverse: !q.forwards,
- sortByTimestamp: q.sort === 'claimed',
+ //sortByTimestamp: q.sort === 'claimed',
+ sortByTimestamp: q.sort || 'claimed',
lt: Number(q.lt) || Date.now(),
gt: Number(q.gt) || -Infinity,
filter: q.filter,