|
|
@ -150,8 +150,8 @@ OutgoingMessage.prototype = {
|
|
|
|
const pubKey = number;
|
|
|
|
const pubKey = number;
|
|
|
|
const ttl = 2 * 24 * 60 * 60;
|
|
|
|
const ttl = 2 * 24 * 60 * 60;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const result = await this.lokiserver.sendMessage(pubKey, JSON.stringify(jsonData), ttl);
|
|
|
|
const [response, status] = await this.lokiserver.sendMessage(pubKey, JSON.stringify(jsonData), ttl);
|
|
|
|
return result;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
catch(e) {
|
|
|
|
if (e.name === 'HTTPError' && (e.code !== 409 && e.code !== 410)) {
|
|
|
|
if (e.name === 'HTTPError' && (e.code !== 409 && e.code !== 410)) {
|
|
|
@ -322,29 +322,6 @@ OutgoingMessage.prototype = {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
sendToNumber(number) {
|
|
|
|
sendToNumber(number) {
|
|
|
|
if (false /* skipEncryption */)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const pubKey = number;
|
|
|
|
|
|
|
|
const data = StringView.bytesToBase64(this.getPlaintext());
|
|
|
|
|
|
|
|
const ttl = 2 * 24 * 60 * 60;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.lokiserver.sendMessage(pubKey, data, ttl).then(
|
|
|
|
|
|
|
|
(result, status) => {
|
|
|
|
|
|
|
|
this.successfulNumbers[this.successfulNumbers.length] = number;
|
|
|
|
|
|
|
|
this.numberCompleted();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
(error) => {
|
|
|
|
|
|
|
|
console.log('Loki sendMessage failed');
|
|
|
|
|
|
|
|
this.registerError(
|
|
|
|
|
|
|
|
number,
|
|
|
|
|
|
|
|
'Failed to send message',
|
|
|
|
|
|
|
|
error
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return this.getStaleDeviceIdsForNumber(number).then(updateDevices =>
|
|
|
|
return this.getStaleDeviceIdsForNumber(number).then(updateDevices =>
|
|
|
|
this.getKeysForNumber(number, updateDevices)
|
|
|
|
this.getKeysForNumber(number, updateDevices)
|
|
|
|
.then(this.reloadDevicesAndSend(number, true))
|
|
|
|
.then(this.reloadDevicesAndSend(number, true))
|
|
|
@ -367,6 +344,5 @@ OutgoingMessage.prototype = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|