git ssb

0+

ev / minbase



Tree: 3ee0398629a78832c2fbe78831ce756faeaeca74

Files: 3ee0398629a78832c2fbe78831ce756faeaeca74 / modules / star.js

1503 bytesRaw
1var h = require('hyperscript')
2var u = require('../util')
3var pull = require('pull-stream')
4var messageLink = require('./helpers').message_link
5
6var config = require('../config')()
7
8exports.needs = {
9 message_confirm: 'first'
10}
11
12exports.gives = {
13 message_content_mini: true,
14 message_action: true
15}
16
17exports.create = function (api) {
18 exports.message_content_mini = function (msg, sbot) {
19 console.log(config.emojiUrl)
20 var star = config.emojiUrl + 'star.png'
21 var stars = config.emojiUrl + 'stars.png'
22 if(msg.value.content.type !== 'vote') return
23 var link = msg.value.content.vote.link
24 return [
25 msg.value.content.vote.value > 0
26 ? h('img', {className: 'emoji', src: star})
27 : h('img', {className: 'emoji', src: stars}),
28 ' ', messageLink(link)
29 ]
30 }
31
32 exports.message_action = function (msg, sbot) {
33 var star = config.emojiUrl + 'star.png'
34 console.log(star)
35 if(msg.value.content.type !== 'vote')
36 return h('a.dig', {href: '#', onclick: function (e) {
37 e.preventDefault()
38 var dig = {
39 type: 'vote',
40 vote: { link: msg.key, value: 1, expression: 'Star' }
41 }
42 if(msg.value.content.recps) {
43 dig.recps = msg.value.content.recps.map(function (e) {
44 return e && typeof e !== 'string' ? e.link : e
45 })
46 dig.private = true
47 }
48 api.message_confirm(dig)
49 }}, h('img', {className: 'emoji', src: star}))
50
51 }
52 return exports
53}
54
55

Built with git-ssb-web