git ssb

16+

Dominic / patchbay



Tree: 56281fc6758e5edb39a262b90900a7e5f0bed393

Files: 56281fc6758e5edb39a262b90900a7e5f0bed393 / modules / like.js

1560 bytesRaw
1
2var h = require('hyperscript')
3var u = require('../util')
4var pull = require('pull-stream')
5
6var plugs = require('../plugs')
7
8var message_confirm = plugs.first(exports.message_confirm = [])
9var message_link = plugs.first(exports.message_link = [])
10var sbot_links = plugs.first(exports.sbot_links = [])
11
12exports.message_content = function (msg, sbot) {
13 if(msg.value.content.type !== 'vote') return
14 var link = msg.value.content.vote.link
15 return h('div',
16 msg.value.content.vote.value > 0 ? 'Dug' : 'Undug',
17 ' ', message_link(link)
18 )
19}
20
21exports.message_meta = function (msg, sbot) {
22 var digs = h('a')
23
24 var votes = []
25 for(var k in CACHE) {
26 if(CACHE[k].content.type == 'vote' &&
27 (CACHE[k].content.vote == msg.key ||
28 CACHE[k].content.vote.link == msg.key
29 ))
30 votes.push({source: CACHE[k].author, dest: k, rel: 'vote'})
31 }
32
33 if(votes.length === 1)
34 digs.textContent = ' 1 Dig'
35 if(votes.length > 1)
36 digs.textContent = ' ' + votes.length + ' Digs'
37
38 return digs
39}
40
41exports.message_action = function (msg, sbot) {
42 if(msg.value.content.type !== 'vote')
43 return h('a.dig', {href: '#', onclick: function () {
44 var dig = {
45 type: 'vote',
46 vote: { link: msg.key, value: 1, expression: 'Dig' }
47 }
48 if(msg.value.content.recps) {
49 dig.recps = msg.value.content.recps.map(function (e) {
50 return e && typeof e !== 'string' ? e.link : e
51 })
52 dig.private = true
53 }
54 //TODO: actually publish...
55
56 message_confirm(dig)
57 }}, 'Dig')
58
59}
60
61

Built with git-ssb-web