Files: e3887a34e8e4f6b4cbc0d1d1b0e549b50157b48c / async / fetch.js
545 bytesRaw
1 | const isBlog = require('../../isBlog') |
2 | |
3 | // TODO take blog or blogKey? |
4 | |
5 | module.exports = function (server) { |
6 | return function fetch (blog, cb) { |
7 | if (!isBlog(blog)) return cb(`Not a valid blog ${JSON.stringify(blog, null, 2)}`) |
8 | |
9 | server.blobs.want(getBlob(blog), (err, success) => { |
10 | if (err) throw err |
11 | |
12 | if (success) cb(null, success) |
13 | else cb(null, 'Could not fetch blog content') |
14 | }) |
15 | } |
16 | } |
17 | |
18 | function getBlob (msg) { |
19 | if (msg.value.content && msg.value.content.content) return obj.value.content |
20 | |
21 | return obj |
22 | } |
23 | |
24 |
Built with git-ssb-web