Fixed some little redundant stuff in the message and snode api
This commit is contained in:
parent
d002d76d9f
commit
38ff70e2ec
|
@ -1128,7 +1128,7 @@ async function getSwarmNodesByPubkey(pubkey) {
|
|||
});
|
||||
|
||||
if (!row) {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
return jsonToObject(row.json).swarmNodes;
|
||||
|
|
|
@ -105,20 +105,15 @@ class LokiMessageAPI {
|
|||
throw HTTPError('sendMessage: error response', response.status, result);
|
||||
};
|
||||
|
||||
let swarmNodes;
|
||||
try {
|
||||
swarmNodes = await window.LokiSnodeAPI.getSwarmNodesByPubkey(pubKey);
|
||||
} catch (e) {
|
||||
throw new window.textsecure.EmptySwarmError(pubKey, e);
|
||||
}
|
||||
let swarmNodes = await window.LokiSnodeAPI.getSwarmNodesByPubkey(pubKey);
|
||||
while (successfulRequests < MINIMUM_SUCCESSFUL_REQUESTS) {
|
||||
if (!canResolve) {
|
||||
throw new window.textsecure.DNSResolutionError('Sending messages');
|
||||
}
|
||||
if (!swarmNodes || swarmNodes.length === 0) {
|
||||
if (swarmNodes.length === 0) {
|
||||
swarmNodes = await window.LokiSnodeAPI.getFreshSwarmNodes(pubKey);
|
||||
swarmNodes = _.difference(swarmNodes, completedNodes);
|
||||
if (!swarmNodes || swarmNodes.length === 0) {
|
||||
if (swarmNodes.length === 0) {
|
||||
if (successfulRequests !== 0) {
|
||||
// TODO: Decide how to handle some completed requests but not enough
|
||||
return;
|
||||
|
|
|
@ -108,10 +108,7 @@ class LokiSnodeAPI {
|
|||
|
||||
async getSwarmNodesByPubkey(pubKey) {
|
||||
const swarmNodes = await window.Signal.Data.getSwarmNodesByPubkey(pubKey);
|
||||
if (swarmNodes) {
|
||||
return swarmNodes;
|
||||
}
|
||||
return [];
|
||||
return swarmNodes;
|
||||
}
|
||||
|
||||
async saveSwarmNodes(pubKey, swarmNodes) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
}
|
||||
|
||||
async function sendOnlineBroadcastMessage(pubKey) {
|
||||
// TODO: Make this actually get a loki address rather than junk string
|
||||
const lokiAddressMessage = new textsecure.protobuf.LokiAddressMessage({
|
||||
p2pAddress: 'testAddress',
|
||||
p2pPort: parseInt(window.localServerPort, 10),
|
||||
|
|
Loading…
Reference in New Issue