Commit f9247af42625faa86a666f3a03671aa524a870a4
fix async route normalise for private messages
mix irving committed on 2/8/2018, 5:16:05 AMParent: a41e049ca3755ddfd97e7f53c9da830711e636f1
Files changed
router/async/normalise.js | changed |
router/async/normalise.js | |||
---|---|---|---|
@@ -2,18 +2,24 @@ | |||
2 | 2 … | const { isBlob, isFeed, isMsg } = require('ssb-ref') | |
3 | 3 … | ||
4 | 4 … | exports.gives = nest('router.async.normalise') | |
5 | 5 … | ||
6 | -exports.needs = nest({'sbot.async.get': 'first'}) | ||
6 … | +exports.needs = nest({ | ||
7 … | + 'message.sync.unbox': 'first', | ||
8 … | + 'sbot.async.get': 'first', | ||
9 … | +}) | ||
7 | 10 … | ||
8 | 11 … | exports.create = (api) => { | |
9 | 12 … | return nest('router.async.normalise', normalise) | |
10 | 13 … | ||
11 | 14 … | function normalise (location, cb) { | |
12 | 15 … | if (typeof location === 'object') cb(null, location) | |
13 | 16 … | else if (isMsg(location)) api.sbot.async.get(location, (err, value) => { | |
14 | 17 … | if (err) cb(err) | |
15 | - else cb(null, {key: location, value}) | ||
18 … | + else { | ||
19 … | + if (typeof value.content === 'string') value = api.message.sync.unbox(value) | ||
20 … | + cb(null, {key: location, value}) | ||
21 … | + } | ||
16 | 22 … | }) | |
17 | 23 … | else if (isBlob(location)) cb(null, { blob: location }) | |
18 | 24 … | else if (isChannel(location)) cb(null, { channel: location }) | |
19 | 25 … | else if (isFeed(location)) cb(null, { feed: location }) |
Built with git-ssb-web