diff options
Diffstat (limited to 'lib/app.js')
-rw-r--r-- | lib/app.js | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -224,11 +224,38 @@ App.prototype.getMsgDecryptedOoo = function (key, cb) { }) } +App.prototype.publishMayRedirect = function (content, cb) { + var publishguard = this.sbot.publishguard + if (Array.isArray(content.recps)) { + var recps = content.recps.map(u.linkDest) + if (publishguard && publishguard.privatePublishGetUrl) { + return publishguard.privatePublishGetUrl({ + content: content, + recps: recps, + redirectBase: this.baseUrl + '/' + }, onPublishGetUrl) + } + this.sbot.private.publish(content, recps, cb) + } else { + if (publishguard && publishguard.publishGetUrl) { + return publishguard.publishGetUrl({ + content: content, + redirectBase: this.baseUrl + '/' + }, onPublishGetUrl) + } + this.sbot.publish(content, cb) + } + function onPublishGetUrl(err, url) { + if (err) return cb(err) + cb({redirectUrl: url}) + } +} + App.prototype.publish = function (content, cb) { var self = this function tryPublish(triesLeft) { if (Array.isArray(content.recps)) { - recps = content.recps.map(u.linkDest) + var recps = content.recps.map(u.linkDest) self.sbot.private.publish(content, recps, next) } else { self.sbot.publish(content, next) |