use SyncMessage when we are only sending a syncMessage

pull/1197/head
Audric Ackermann 5 years ago
parent 1b011ca74e
commit 24f86de087
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1628,11 +1628,9 @@
timestamp: Date.now(),
reqestType: CONFIGURATION,
});
const myPubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(myPubKey);
await libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, requestConfigurationSyncMessage);
.sendSyncMessage(requestConfigurationSyncMessage);
// sending of the message is handled in the 'private' case below
}
}

@ -379,14 +379,9 @@ MessageSender.prototype = {
const syncMessages = await Promise.all(
chunked.map(c => libloki.api.createContactSyncMessage(c))
);
const pubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(pubKey);
const syncPromises = syncMessages.map(syncMessage =>
libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, syncMessage)
libsession.getMessageQueue().sendSyncMessage(syncMessage)
);
return Promise.all(syncPromises);
@ -412,17 +407,13 @@ MessageSender.prototype = {
window.console.info('No closed group to sync.');
return Promise.resolve();
}
const pubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(pubKey);
// We need to sync across 1 group at a time
// This is because we could hit the storage server limit with one group
const syncPromises = sessionGroups
.map(c => libloki.api.createGroupSyncMessage(c))
.map(syncMessage =>
libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, syncMessage)
libsession.getMessageQueue().sendSyncMessage(syncMessage)
);
return Promise.all(syncPromises);
@ -458,12 +449,7 @@ MessageSender.prototype = {
openGroupsSyncParams
);
const pubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(pubKey);
return libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, openGroupsSyncMessage);
return libsession.getMessageQueue().sendSyncMessage(openGroupsSyncMessage);
},
syncReadMessages(reads) {
const myDevice = textsecure.storage.user.getDeviceId();
@ -474,11 +460,7 @@ MessageSender.prototype = {
readMessages: reads,
}
);
const pubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(pubKey);
return libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, syncReadMessages);
return libsession.getMessageQueue().sendSyncMessage(syncReadMessages);
}
return Promise.resolve();
@ -510,26 +492,8 @@ MessageSender.prototype = {
const verifiedSyncMessage = new window.libsession.Messages.Outgoing.VerifiedSyncMessage(
verifiedSyncParams
);
const pubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(pubKey);
return libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, verifiedSyncMessage);
},
getOurProfile() {
try {
// Secondary devices have their profile stored
// in their primary device's conversation
const ourNumber = window.storage.get('primaryDevicePubKey');
const conversation = window.ConversationController.get(ourNumber);
return conversation.getLokiProfile();
} catch (e) {
window.log.error(`Failed to get our profile: ${e}`);
return null;
}
return libsession.getMessageQueue().sendSyncMessage(verifiedSyncMessage);
},
makeProxiedRequest(url, options) {

@ -24,13 +24,9 @@
reqestType: CONFIGURATION,
});
const pubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(pubKey);
await libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, requestConfigurationSyncMessage);
.sendSyncMessage(requestConfigurationSyncMessage);
window.log.info('SyncRequest now sending contact sync message...');
const { CONTACTS } = textsecure.protobuf.SyncMessage.Request.Type;
@ -40,7 +36,7 @@
});
await libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, requestContactSyncMessage);
.sendSyncMessage(requestContactSyncMessage);
window.log.info('SyncRequest now sending group sync messsage...');
const { GROUPS } = textsecure.protobuf.SyncMessage.Request.Type;
@ -48,9 +44,7 @@
timestamp: Date.now(),
reqestType: GROUPS,
});
await libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, requestGroupSyncMessage);
await libsession.getMessageQueue().sendSyncMessage(requestGroupSyncMessage);
this.timeout = setTimeout(this.onTimeout.bind(this), 60000);
}

Loading…
Cancel
Save