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