git ssb

0+

Piet / ssb-loomio



Tree: f81bab2f5e5f60995b99ed6d9b588e91f0c47d1f

Files: f81bab2f5e5f60995b99ed6d9b588e91f0c47d1f / position / sync / position.js

1401 bytesRaw
1// var { link } = require('ssb-msg-schemas/util')
2
3function Position ({ poll, positionDetails, reason, channel, recps, mentions }) {
4 var content = { type: 'position', poll, positionDetails, reason }
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
38module.exports = Position
39

Built with git-ssb-web