var Sort = require('ssb-sort') var Reduce = require('./reduce') var pull = require('pull-stream') module.exports = function (sbot, id, cb) { sbot.get(id, function (err, msg) { pull( sbot.links({ dest: id, values: true }), pull.collect(function (err, ary) { ary = ary.filter(function (e) { return e.value.content.type == 'tag' || e.value.content.type == 'about' }) ary.unshift({key: id, value:msg}) ary = Sort(ary) var tag = ary.reduce(Reduce, null) tag.branch = Sort.heads(ary) cb(null, tag) }) ) }) }