aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-05-01 16:51:09 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-05-01 16:51:09 -1000
commita73918fe22e481b5f44479740dd3d5910970bf6f (patch)
tree692933b5f1f5a6167f8cc45b03e06b9abea62a21 /lib/app.js
parent7750ee481b305ff8789ca9813da2c62182b25b06 (diff)
downloadpatchfoo-a73918fe22e481b5f44479740dd3d5910970bf6f.tar.gz
patchfoo-a73918fe22e481b5f44479740dd3d5910970bf6f.zip
Handle boxed markdown blobs
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js17
1 files changed, 17 insertions, 0 deletions
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)