diff options
-rw-r--r-- | lib/app.js | 4 | ||||
-rw-r--r-- | lib/serve.js | 3 | ||||
-rw-r--r-- | lib/util.js | 11 |
3 files changed, 10 insertions, 8 deletions
@@ -828,8 +828,10 @@ App.prototype.streamMentions = function (opts) { } App.prototype.streamPrivate = function (opts) { - if (this.sbot.private && this.sbot.private.read) + if (this.sbot.private && this.sbot.private.read) { + if (opts.sortByTimestamp) return pull.error('ssb-private does not support sort by claimed timestamp') return this.filter(this.sbot.private, opts, {}) + } return pull( this.createLogStream(u.mergeOpts(opts, {private: true})), diff --git a/lib/serve.js b/lib/serve.js index 685faa6..d780024 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -644,6 +644,7 @@ Serve.prototype.new = function (ext) { Serve.prototype.private = function (ext) { var q = this.query var opts = { + sortByTimestamp: q.sort === 'claimed', reverse: !q.forwards, lt: Number(q.lt) || Date.now(), gt: Number(q.gt) || -Infinity, @@ -1764,6 +1765,7 @@ Serve.prototype.type = function (path) { var q = this.query var type = decodeURIComponent(path.substr(1)) var opts = { + sortByTimestamp: q.sort === 'claimed', reverse: !q.forwards, lt: Number(q.lt) || Date.now(), gt: Number(q.gt) || -Infinity, @@ -1829,6 +1831,7 @@ Serve.prototype.channel = function (path) { var gt = Number(q.gt) || -Infinity var lt = Number(q.lt) || Date.now() var opts = { + sortByTimestamp: q.sort === 'claimed', reverse: !q.forwards, lt: lt, gt: gt, diff --git a/lib/util.js b/lib/util.js index c5584ee..519289a 100644 --- a/lib/util.js +++ b/lib/util.js @@ -220,14 +220,11 @@ u.pullSlice = function (start, end) { } u.mergeOpts = function (a, b) { + if (typeof b !== 'object' || b === null) return b + if (typeof a !== 'object' || a === null) return a var obj = {}, k - for (k in a) { - obj[k] = a[k] - } - for (k in b) { - if (b[k] != null) obj[k] = b[k] - else delete obj[k] - } + for (k in a) obj[k] = k in b ? u.mergeOpts(a[k], b[k]) : a[k] + for (k in b) if (!(k in a) && b[k] != null) obj[k] = b[k] return obj } |