Add replayable network errors
Support for manual message retry. // FREEBIE
This commit is contained in:
parent
bc03bdbfc4
commit
fbb65d1988
4 changed files with 60 additions and 2 deletions
|
@ -37,10 +37,19 @@ MessageSender.prototype = {
|
|||
});
|
||||
})).then(function(jsonData) {
|
||||
var legacy = (message instanceof textsecure.protobuf.DataMessage);
|
||||
return this.server.sendMessages(number, jsonData, legacy);
|
||||
return this.sendRequest(number, jsonData, legacy);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
sendRequest: function(number, jsonData, legacy) {
|
||||
return this.server.sendMessages(number, jsonData, legacy).catch(function(e) {
|
||||
if (e.name === 'HTTPError' && e.code === -1) {
|
||||
throw new NetworkError(number, jsonData, legacy);
|
||||
}
|
||||
throw e;
|
||||
});
|
||||
},
|
||||
|
||||
makeAttachmentPointer: function(attachment) {
|
||||
if (typeof attachment !== 'object' || attachment == null) {
|
||||
return Promise.resolve(undefined);
|
||||
|
@ -424,6 +433,7 @@ window.textsecure = window.textsecure || {};
|
|||
textsecure.MessageSender = function(url, username, password) {
|
||||
var sender = new MessageSender(url, username, password);
|
||||
textsecure.replay.registerFunction(sender.tryMessageAgain.bind(sender), textsecure.replay.Type.SEND_MESSAGE);
|
||||
textsecure.replay.registerFunction(sender.sendRequest.bind(sender), textsecure.replay.Type.NETWORK_REQUEST);
|
||||
|
||||
this.sendRequestGroupSyncMessage = sender.sendRequestGroupSyncMessage .bind(sender);
|
||||
this.sendRequestContactSyncMessage = sender.sendRequestContactSyncMessage.bind(sender);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue