git ssb

0+

Dominic / yap-patch



Tree: 634a3e47dc6133cc55dae03d47dc86880af6282c

Files: 634a3e47dc6133cc55dae03d47dc86880af6282c / likes.js

1091 bytesRaw
1var ref = require('ssb-ref')
2var pull = require('pull-stream')
3
4module.exports = function (sbot) {
5 return function (opts, apply, req) {
6 id = req.cookies.id || sbot.id
7 if(!ref.isMsg(opts.root)) throw new Error('/likes requires msg root')
8// console.log('Likes', opts)
9 var expression = 'Yup'
10 return function (cb) {
11 pull(
12 sbot.links({dest: opts.id, rel: 'vote'}),
13 pull.collect(function (err, ary) {
14 // return cb(null, ['button', 'Yup2'])
15
16 cb(null, apply('publish', {
17 id: id,
18// suggestedRecps: data.value.author,
19 content: {
20 type: 'vote',
21 root: opts.root, branch: opts.branch,
22 vote: {
23 link:opts.id, value: 1,
24 expression: expression//Tr(req.cookies.lang)('Like')
25 },
26 channel: opts.channel,
27 recps: opts.recps
28 },
29 name: expression + ' ' + (ary.length ? '('+ary.length+')' : '')
30 })
31 )
32 })
33 )
34 }
35 }
36}
37

Built with git-ssb-web