aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-02-03 15:36:36 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-02-03 15:36:36 -1000
commit8985feb5e74cf17eb5e2a24977b677047c441fcc (patch)
treefc6395d317eab7b7814c18639a76e820e9d655c8 /lib/app.js
parentda132772a40f9291abbc5fd997591e32d9f65268 (diff)
downloadpatchfoo-8985feb5e74cf17eb5e2a24977b677047c441fcc.tar.gz
patchfoo-8985feb5e74cf17eb5e2a24977b677047c441fcc.zip
Support private publish without ssb-private
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/app.js b/lib/app.js
index 3847247..0cc2702 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -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)
}