Commit 14e118e9daffeaae72c39c493c18827986a23ee6
Use schema version constant rather than magic string
Piet Geursen committed on 3/15/2018, 9:16:47 PMParent: 5a278075ec43325cf000c2fcb66c71b38a75df86
Files changed
poll/sync/poll.js | changed |
position/async/position.js | changed |
types.js | changed |
poll/sync/poll.js | ||
---|---|---|
@@ -1,8 +1,9 @@ | ||
1 | 1 | // var { link } = require('ssb-msg-schemas/util') |
2 | +const {SCHEMA_VERSION} = require('../../types') | |
2 | 3 | |
3 | 4 | function Poll ({ details, title, closesAt, body, channel, recps, mentions }) { |
4 | - var content = { type: 'poll', details, title, closesAt, version: 'v1' } | |
5 | + var content = { type: 'poll', details, title, closesAt, version: SCHEMA_VERSION } | |
5 | 6 | |
6 | 7 | if (body) content.body = body |
7 | 8 | |
8 | 9 | // if (root) { |
position/async/position.js | ||
---|---|---|
@@ -1,6 +1,8 @@ | ||
1 | +const sort = require('ssb-sort') | |
2 | + | |
1 | 3 | const GetPoll = require('../../poll/async/get') |
2 | -const sort = require('ssb-sort') | |
4 | +const {SCHEMA_VERSION} = require('../../types') | |
3 | 5 | // var { link } = require('ssb-msg-schemas/util') |
4 | 6 | // |
5 | 7 | |
6 | 8 | module.exports = function (server) { |
@@ -8,9 +10,9 @@ | ||
8 | 10 | |
9 | 11 | return function Position ({ poll = {}, details, reason, channel, mentions }, cb) { |
10 | 12 | const content = { |
11 | 13 | type: 'position', |
12 | - version: 'v1', | |
14 | + version: SCHEMA_VERSION, | |
13 | 15 | root: typeof poll === 'string' ? poll : poll.key, |
14 | 16 | details |
15 | 17 | } |
16 | 18 |
types.js | ||
---|---|---|
@@ -1,9 +1,10 @@ | ||
1 | 1 | module.exports = { |
2 | 2 | CHOOSE_ONE: 'chooseOne', |
3 | 3 | ERROR_POSITION_TYPE: 'ERROR_POSITION_TYPE', |
4 | 4 | ERROR_POSITION_LATE: 'ERROR_POSITION_LATE', |
5 | - ERROR_POSITION_CHOICE: 'ERROR_POSITION_CHOICE' | |
5 | + ERROR_POSITION_CHOICE: 'ERROR_POSITION_CHOICE', | |
6 | + SCHEMA_VERSION: 'v1' | |
6 | 7 | } |
7 | 8 | |
8 | 9 | // Question: do these need to be different, could we just have 'chooseOne', |
9 | 10 | // because we already have: |
Built with git-ssb-web