var ref = require('ssb-ref') var pull = require('pull-stream') module.exports = function (sbot) { return function (opts, apply, req) { id = req.cookies.id || sbot.id if(!ref.isMsg(opts.root)) throw new Error('/likes requires msg root') // console.log('Likes', opts) var expression = 'Yup' return function (cb) { pull( sbot.links({dest: opts.id, rel: 'vote'}), pull.collect(function (err, ary) { // return cb(null, ['button', 'Yup2']) cb(null, apply('publish', { id: id, // suggestedRecps: data.value.author, content: { type: 'vote', root: opts.root, branch: opts.branch, vote: { link:opts.id, value: 1, expression: expression//Tr(req.cookies.lang)('Like') }, channel: opts.channel, recps: opts.recps }, name: expression + ' ' + (ary.length ? '('+ary.length+')' : '') }) ) }) ) } } }