|
|
|
@ -146,26 +146,30 @@ OutgoingMessage.prototype = {
|
|
|
|
|
return promise;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
transmitMessage(number, jsonData, timestamp) {
|
|
|
|
|
return this.server
|
|
|
|
|
.sendMessages(number, jsonData, timestamp, this.silent)
|
|
|
|
|
.catch(e => {
|
|
|
|
|
if (e.name === 'HTTPError' && (e.code !== 409 && e.code !== 410)) {
|
|
|
|
|
// 409 and 410 should bubble and be handled by doSendMessage
|
|
|
|
|
// 404 should throw UnregisteredUserError
|
|
|
|
|
// all other network errors can be retried later.
|
|
|
|
|
if (e.code === 404) {
|
|
|
|
|
throw new textsecure.UnregisteredUserError(number, e);
|
|
|
|
|
}
|
|
|
|
|
throw new textsecure.SendMessageNetworkError(
|
|
|
|
|
number,
|
|
|
|
|
jsonData,
|
|
|
|
|
e,
|
|
|
|
|
timestamp
|
|
|
|
|
);
|
|
|
|
|
async transmitMessage(number, jsonData, timestamp) {
|
|
|
|
|
const pubKey = number;
|
|
|
|
|
const ttl = 2 * 24 * 60 * 60;
|
|
|
|
|
try {
|
|
|
|
|
const result = await this.lokiserver.sendMessage(pubKey, JSON.stringify(jsonData), ttl);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
if (e.name === 'HTTPError' && (e.code !== 409 && e.code !== 410)) {
|
|
|
|
|
// 409 and 410 should bubble and be handled by doSendMessage
|
|
|
|
|
// 404 should throw UnregisteredUserError
|
|
|
|
|
// all other network errors can be retried later.
|
|
|
|
|
if (e.code === 404) {
|
|
|
|
|
throw new textsecure.UnregisteredUserError(number, e);
|
|
|
|
|
}
|
|
|
|
|
throw e;
|
|
|
|
|
});
|
|
|
|
|
throw new textsecure.SendMessageNetworkError(
|
|
|
|
|
number,
|
|
|
|
|
jsonData,
|
|
|
|
|
e,
|
|
|
|
|
timestamp
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getPaddedMessageLength(messageLength) {
|
|
|
|
|