git ssb

0+

Piet / ssb-loomio



Tree: be47c4200236fb818783a444f2a01b0707ec0a46

Files: be47c4200236fb818783a444f2a01b0707ec0a46 / position / async / position.js

1284 bytesRaw
1const { isMsg: isMsgRef } = require('ssb-ref')
2// var { link } = require('ssb-msg-schemas/util')
3
4function Position ({ poll = {}, details, reason, channel, mentions }, cb) {
5 const content = {
6 type: 'position',
7 root: typeof poll === 'string' ? poll : poll.key,
8 details
9 }
10
11 if (reason) content.reason = reason
12
13 // TODO branch should be calculated
14 // ... this needs to be async... unless all messages are passed in
15
16 // // NOTE mentions can be derived from text,
17 // // or we could leave it so you can manually notify people without having to at-mention spam the text
18 // if (mentions && (!Array.isArray(mentions) || mentions.length)) {
19 // mentions = links(mentions)
20 // if (!mentions || !mentions.length) { throw new Error('mentions are not valid links') }
21 // content.mentions = mentions
22 // }
23
24 // // NOTE recps should be derived from the poll I think
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 cb(null, content)
36}
37
38module.exports = Position
39

Built with git-ssb-web