aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-11-29 15:21:15 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-11-29 15:21:15 -1000
commit35fd4cfba80c0e434d082778e6105629165b33d7 (patch)
tree4c9f7c170de8af353cbbfe6f4455c2cf221360fb /lib/app.js
parentf7500c061f257feca2bccf3c51616110589cfa0e (diff)
downloadpatchfoo-35fd4cfba80c0e434d082778e6105629165b33d7.tar.gz
patchfoo-35fd4cfba80c0e434d082778e6105629165b33d7.zip
Integrate with ssb-publishguard redirects
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/app.js b/lib/app.js
index fb27e78..b4da954 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -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)