aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-06-12 15:35:25 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-06-12 15:35:25 -1000
commitdb2d73a056dc9c807827b42db337ba460dd730b2 (patch)
treef03e2347ef61075596d98aa3b1a46fc487629efd /lib
parent631791d5345cbc1c29fc844d5785139dff746958 (diff)
downloadpatchfoo-db2d73a056dc9c807827b42db337ba460dd730b2.tar.gz
patchfoo-db2d73a056dc9c807827b42db337ba460dd730b2.zip
Use ssb-private for private page
Diffstat (limited to 'lib')
-rw-r--r--lib/app.js20
-rw-r--r--lib/serve.js9
2 files changed, 22 insertions, 7 deletions
diff --git a/lib/app.js b/lib/app.js
index 3ff8b81..eca2a9f 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -521,3 +521,23 @@ App.prototype.streamMentions = function (opts) {
}}]
}))
}
+
+App.prototype.streamPrivate = function (opts) {
+ if (this.sbot.private.read) return this.sbot.private.read(u.mergeOpts(opts, {
+ query: [{$filter: {
+ timestamp: {
+ $gt: opts.gt,
+ $lt: opts.lt,
+ }
+ }}]
+ }))
+
+
+ return pull
+ this.createLogStream(u.mergeOpts(opts, {limit: null}),
+ pull.filter(u.isMsgEncrypted),
+ this.unboxMessages(),
+ pull.filter(u.isMsgReadable),
+ pull.take(opts.limit)
+ )
+}
diff --git a/lib/serve.js b/lib/serve.js
index 3e20a0f..32ea3e0 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -390,18 +390,13 @@ Serve.prototype.private = 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,
+ limit: Number(q.limit) || 12,
}
- var limit = Number(q.limit) || 12
pull(
- this.app.createLogStream(opts),
- pull.filter(u.isMsgEncrypted),
- this.app.unboxMessages(),
- pull.filter(u.isMsgReadable),
- pull.take(limit),
+ this.app.streamPrivate(opts),
this.renderThreadPaginated(opts, null, q),
this.wrapMessages(),
this.wrapPrivate(opts),