diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-04-14 00:48:57 -0700 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-04-14 12:57:34 -0700 |
commit | 34bf49e52db38a53d14c19c65d775f52da0c1329 (patch) | |
tree | 609af342a5dce6a599bbca6cca41cc3f081256fc /lib/serve.js | |
parent | 3b2abbd473b007b9de5f8b76c8e74aad26b947be (diff) | |
download | patchfoo-34bf49e52db38a53d14c19c65d775f52da0c1329.tar.gz patchfoo-34bf49e52db38a53d14c19c65d775f52da0c1329.zip |
Move message stream decryption into App
Diffstat (limited to 'lib/serve.js')
-rw-r--r-- | lib/serve.js | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/serve.js b/lib/serve.js index ca86533..e7d1695 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -25,11 +25,6 @@ var emojiDir = path.join(require.resolve('emoji-named-characters'), '../pngs') var urlIdRegex = /^(?:\/+(([%&@]|%25)(?:[A-Za-z0-9\/+]|%2[Ff]|%2[Bb]){43}(?:=|%3D)\.(?:sha256|ed25519))(?:\.([^?]*))?|(\/.*?))(?:\?(.*))?$/ -function isMsgReadable(msg) { - var c = msg && msg.value.content - return typeof c === 'object' && c !== null -} - function isMsgEncrypted(msg) { var c = msg && msg.value.content return typeof c === 'string' @@ -323,8 +318,7 @@ Serve.prototype.private = function (ext) { pull( this.app.createLogStream(opts), pull.filter(isMsgEncrypted), - paramap(this.app.unboxMsg, 16), - pull.filter(isMsgReadable), + this.app.unboxMessages(), pull.take(limit), this.renderThreadPaginated(opts, null, q), this.wrapMessages(), @@ -412,13 +406,7 @@ Serve.prototype.channels = function (ext) { var self = this pull( - self.app.sbot.messagesByType({type: 'channel', reverse: true}), - paramap(self.app.unboxMsg, 16), - pull.map(function (msg) { - var c = msg.value.content - return c && c.channel - }), - pull.unique(), + self.app.streamChannels(), paramap(function (channel, cb) { var subscribed = false cb(null, h('form', {method: 'post', action: ''}, @@ -565,7 +553,7 @@ Serve.prototype.id = function (id, ext) { pull( cat([pull.once(rootMsg), self.app.sbot.links({dest: id, values: true})]), pull.unique('key'), - paramap(self.app.unboxMsg, 16), + self.app.unboxMessages(), pull.collect(function (err, links) { if (err) return self.respond(500, err.stack || err) pull( @@ -1230,7 +1218,7 @@ Serve.prototype.composer = function (opts, cb) { var msgContainer = h('table.ssb-msgs') pull( pull.once(msg), - pull.asyncMap(self.app.unboxMsg), + self.app.unboxMessages(), self.app.render.renderFeeds(raw), pull.drain(function (el) { msgContainer.appendChild(h('tbody', el)) |