From a73918fe22e481b5f44479740dd3d5910970bf6f Mon Sep 17 00:00:00 2001 From: cel Date: Wed, 1 May 2019 16:51:09 -1000 Subject: Handle boxed markdown blobs --- lib/app.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index 3803281..9da761e 100644 --- a/lib/app.js +++ b/lib/app.js @@ -379,6 +379,13 @@ App.prototype.addBlobPrivate = function (cb) { } App.prototype.getBlob = function (id, key) { + if (!key) { + var m = /^(.*)\?unbox=(.*)$/.exec(id) + if (m) { + id = m[1] + key = m[2] + } + } if (!key) return this.sbot.blobs.get(id) if (typeof key === 'string') key = new Buffer(key, 'base64') return pull( @@ -387,6 +394,16 @@ App.prototype.getBlob = function (id, key) { ) } +App.prototype.getHasBlob = function (id, cb) { + id = id.replace(/\?unbox=.*/, '') + if (!this.sbot.blobs) return cb(new TypeError('missing ssb-blobs plugin')) + if (!this.sbot.blobs.size) return cb(new TypeError('missing blobs.size method')) + this.sbot.blobs.size(id, function (err, size) { + if (err) return cb(err) + cb(null, size != null) + }) +} + App.prototype.pushBlob = function (id, cb) { console.error('pushing blob', id) this.sbot.blobs.push(id, cb) -- cgit v1.2.3