git ssb

16+

Dominic / patchbay



Commit f9247af42625faa86a666f3a03671aa524a870a4

fix async route normalise for private messages

mix irving committed on 2/8/2018, 5:16:05 AM
Parent: a41e049ca3755ddfd97e7f53c9da830711e636f1

Files changed

router/async/normalise.jschanged
router/async/normalise.jsView
@@ -2,18 +2,24 @@
22 const { isBlob, isFeed, isMsg } = require('ssb-ref')
33
44 exports.gives = nest('router.async.normalise')
55
6-exports.needs = nest({'sbot.async.get': 'first'})
6 +exports.needs = nest({
7 + 'message.sync.unbox': 'first',
8 + 'sbot.async.get': 'first',
9 +})
710
811 exports.create = (api) => {
912 return nest('router.async.normalise', normalise)
1013
1114 function normalise (location, cb) {
1215 if (typeof location === 'object') cb(null, location)
1316 else if (isMsg(location)) api.sbot.async.get(location, (err, value) => {
1417 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 + }
1622 })
1723 else if (isBlob(location)) cb(null, { blob: location })
1824 else if (isChannel(location)) cb(null, { channel: location })
1925 else if (isFeed(location)) cb(null, { feed: location })

Built with git-ssb-web