From 8985feb5e74cf17eb5e2a24977b677047c441fcc Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 3 Feb 2019 15:36:36 -1000 Subject: Support private publish without ssb-private --- lib/app.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/app.js') 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) } -- cgit v1.2.3