Files: 92693260135502dac86a07eef9c477fb0198568a / position / sync / position.js
1293 bytesRaw
1 | const { isMsg: isMsgRef } = require('ssb-ref') |
2 | // var { link } = require('ssb-msg-schemas/util') |
3 | |
4 | function Position ({ poll = {}, positionDetails, reason, channel, mentions }) { |
5 | const content = { |
6 | type: 'position', |
7 | root: typeof poll === 'string' ? poll : poll.key, |
8 | positionDetails |
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 | return content |
36 | } |
37 | |
38 | module.exports = Position |
39 |
Built with git-ssb-web