Files: ee66696629dc72e9da2c959f1baa0c55642d1aa4 / x.js
868 bytesRaw
1 | var pull = require('pull-stream') |
2 | var paramap = require('pull-paramap') |
3 | var ssbClient = require('ssb-client') |
4 | var avatar = require('ssb-avatar') |
5 | var render = require('./render') |
6 | |
7 | var listMessages = function () { |
8 | var number = process.argv[2] |
9 | var type = process.argv[3] |
10 | |
11 | ssbClient(function (err, sbot) { |
12 | if (err) throw err |
13 | sbot.whoami(function getId(err, me) { |
14 | if (err) throw err |
15 | pull( |
16 | sbot.messagesByType({ |
17 | type: type, |
18 | limit: Number(number), |
19 | reverse: true |
20 | }), |
21 | paramap(function getAvatar(msg, cb) { |
22 | avatar(sbot, me.id, msg.value.author, function (err, avatar) { |
23 | if (err) throw err |
24 | msg.avatar = avatar |
25 | cb(null, msg) |
26 | }) |
27 | }), |
28 | pull.drain(function (msg) { |
29 | render(msg) |
30 | }) |
31 | ) |
32 | }) |
33 | }) |
34 | } |
35 | |
36 | listMessages() |
37 |
Built with git-ssb-web