diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-02-03 15:36:36 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-02-03 15:36:36 -1000 |
commit | 8985feb5e74cf17eb5e2a24977b677047c441fcc (patch) | |
tree | fc6395d317eab7b7814c18639a76e820e9d655c8 | |
parent | da132772a40f9291abbc5fd997591e32d9f65268 (diff) | |
download | patchfoo-8985feb5e74cf17eb5e2a24977b677047c441fcc.tar.gz patchfoo-8985feb5e74cf17eb5e2a24977b677047c441fcc.zip |
Support private publish without ssb-private
-rw-r--r-- | lib/app.js | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -289,7 +289,7 @@ App.prototype.publishMayRedirect = function (content, cb) { redirectBase: this.baseUrl + '/' }, onPublishGetUrl) } - this.sbot.private.publish(content, recps, cb) + this.privatePublish(content, recps, cb) } else { if (publishguard && publishguard.publishGetUrl) { return publishguard.publishGetUrl({ @@ -305,12 +305,22 @@ App.prototype.publishMayRedirect = function (content, cb) { } } +App.prototype.privatePublish = function (content, recps, cb) { + if (this.private && typeof this.private.publish === 'function') { + return this.sbot.private.publish(content, recps, cb) + } else { + try { content = ssbKeys.box(content, recps) } + catch(e) { return cb(e) } + return this.sbot.publish(content, cb) + } +} + App.prototype.publish = function (content, cb) { var self = this function tryPublish(triesLeft) { if (Array.isArray(content.recps)) { var recps = content.recps.map(u.linkDest) - self.sbot.private.publish(content, recps, next) + self.privatePublish(content, recps, next) } else { self.sbot.publish(content, next) } |