aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/app.js b/lib/app.js
index 38f9f50..7424b50 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -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()
+ )
+}