diff options
Diffstat (limited to 'lib/app.js')
-rw-r--r-- | lib/app.js | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -7,12 +7,18 @@ var pull = require('pull-stream') var ssbAvatar = require('ssb-avatar') var hasher = require('pull-hash/ext/ssb') var multicb = require('multicb') +var paramap = require('pull-paramap') var Serve = require('./serve') var Render = require('./render') module.exports = App +function isMsgReadable(msg) { + var c = msg && msg.value && msg.value.content + return typeof c === 'object' && c !== null +} + function App(sbot, config) { this.sbot = sbot this.config = config @@ -278,3 +284,21 @@ App.prototype._getFriendInfo = function (id, cb) { }) }) } + +App.prototype.unboxMessages = function () { + return pull( + paramap(this.unboxMsg, 16), + pull.filter(isMsgReadable) + ) +} + +App.prototype.streamChannels = function (opts) { + return pull( + this.sbot.messagesByType({type: 'channel', reverse: true}), + this.unboxMessages(), + pull.map(function (msg) { + return msg.value.content.channel + }), + pull.unique() + ) +} |