git ssb

16+

Dominic / patchbay



Tree: 0e8b5960a55bb51280320035b8d4cb1ecd883988

Files: 0e8b5960a55bb51280320035b8d4cb1ecd883988 / modules / like.js

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

Built with git-ssb-web