git ssb

0+

Piet / ssb-loomio



Tree: 0e0922a38a178fc20c0532642828075f0de37a72

Files: 0e0922a38a178fc20c0532642828075f0de37a72 / poll / sync / poll.js

1426 bytesRaw
1// var { link } = require('ssb-msg-schemas/util')
2
3function Poll ({ pollDetails, title, closesAt, body, channel, recps, mentions }) {
4 var content = { type: 'poll', pollDetails, title, closesAt }
5
6 if (body) content.body = body
7
8 // if (root) {
9 // root = link(root)
10 // if (!root) { throw new Error('root is not a valid link') }
11 // content.root = root
12 // }
13 // if (branch) {
14 // if (!root) { throw new Error('root is not a valid link') }
15 // branch = Array.isArray(branch) ? branch.map(link) : link(branch)
16 // if (!branch) { throw new Error('branch is not a valid link') }
17 // content.branch = branch
18 // }
19 //
20 // // NOTE mentions can be derived from text,
21 // // or we could leave it so you can manually notify people without having to at-mention spam the text
22 // if (mentions && (!Array.isArray(mentions) || mentions.length)) {
23 // mentions = links(mentions)
24 // if (!mentions || !mentions.length) { throw new Error('mentions are not valid links') }
25 // content.mentions = mentions
26 // }
27 // if (recps && (!Array.isArray(recps) || recps.length)) {
28 // recps = links(recps)
29 // if (!recps || !recps.length) { throw new Error('recps are not valid links') }
30 // content.recps = recps
31 // }
32 if (channel) {
33 if (typeof channel !== 'string') { throw new Error('channel must be a string') }
34 content.channel = channel
35 }
36
37 return content
38}
39
40module.exports = Poll
41

Built with git-ssb-web