git ssb

1+

Daan Patchwork / patchwork



Tree: 1b789e63aa59f5d3e5539a4432c8b3c466977a0e

Files: 1b789e63aa59f5d3e5539a4432c8b3c466977a0e / lib / resolve-abouts.js

879 bytesRaw
1const pull = require('pull-stream')
2const extend = require('xtend')
3const Paramap = require('pull-paramap')
4
5module.exports = function ({ ssb }) {
6 return pull(
7 Paramap((msg, cb) => {
8 const type = msg.value && msg.value.content && msg.value.content.type
9 if (type === 'gathering') {
10 resolveGathering(msg, cb)
11 } else {
12 cb(null, msg)
13 }
14 }, 10)
15 )
16
17 function resolveGathering (msg, cb) {
18 ssb.about.latestValues({
19 keys: ['title', 'description', 'location', 'startDateTime', 'image'],
20 dest: msg.key
21 }, (err, gathering) => {
22 if (err) return cb(err)
23 ssb.about.socialValues({
24 key: 'attendee',
25 dest: msg.key
26 }, (err, attending) => {
27 if (err) return cb(err)
28 gathering.attending = Object.keys(attending)
29 cb(null, extend(msg, { gathering }))
30 })
31 })
32 }
33}
34

Built with git-ssb-web