aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/app.js24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/app.js b/lib/app.js
index 25cb02c..6314284 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -100,12 +100,26 @@ App.prototype.getMsgDecrypted = function (key, cb) {
}
App.prototype.publish = function (content, cb) {
- if (Array.isArray(content.recps)) {
- recps = content.recps.map(u.linkDest)
- this.sbot.private.publish(content, recps, cb)
- } else {
- this.sbot.publish(content, cb)
+ var self = this
+ function tryPublish(triesLeft) {
+ if (Array.isArray(content.recps)) {
+ recps = content.recps.map(u.linkDest)
+ self.sbot.private.publish(content, recps, next)
+ } else {
+ self.sbot.publish(content, next)
+ }
+ function next(err, msg) {
+ if (err) {
+ if (triesLeft > 0) {
+ if (/^expected previous:/.test(err.message)) {
+ return tryPublish(triesLeft-1)
+ }
+ }
+ }
+ return cb(err, msg)
+ }
}
+ tryPublish(2)
}
App.prototype.addBlob = function (cb) {