From e1743f3bb0bb6cb958d33b39a2670cd2b7c5b556 Mon Sep 17 00:00:00 2001 From: TylerSchroederWM <75996872+TylerSchroederWM@users.noreply.github.com> Date: Mon, 1 Feb 2021 11:55:20 -0500 Subject: patchfoo integration pt. 1 --- README.md | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index b14de57..34ecf10 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,108 @@ clientFactory(function(err, client) { }); }); ``` + +To integrate into Patchfoo: +``` +Serve.prototype.logbook = 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, + } + + logbook.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) + //}) + //) +} +```Serve.prototype.logbook = 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, + } + + logbook.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) + //}) + //) +} -- cgit v1.2.3