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(), timestamp: Date.now(),
reqestType: CONFIGURATION, reqestType: CONFIGURATION,
}); });
const myPubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(myPubKey);
await libsession await libsession
.getMessageQueue() .getMessageQueue()
.sendUsingMultiDevice(currentPubKey, requestConfigurationSyncMessage); .sendSyncMessage(requestConfigurationSyncMessage);
// sending of the message is handled in the 'private' case below // sending of the message is handled in the 'private' case below
} }
} }

@ -379,14 +379,9 @@ MessageSender.prototype = {
const syncMessages = await Promise.all( const syncMessages = await Promise.all(
chunked.map(c => libloki.api.createContactSyncMessage(c)) 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 => const syncPromises = syncMessages.map(syncMessage =>
libsession libsession.getMessageQueue().sendSyncMessage(syncMessage)
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, syncMessage)
); );
return Promise.all(syncPromises); return Promise.all(syncPromises);
@ -412,17 +407,13 @@ MessageSender.prototype = {
window.console.info('No closed group to sync.'); window.console.info('No closed group to sync.');
return Promise.resolve(); 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 // We need to sync across 1 group at a time
// This is because we could hit the storage server limit with one group // This is because we could hit the storage server limit with one group
const syncPromises = sessionGroups const syncPromises = sessionGroups
.map(c => libloki.api.createGroupSyncMessage(c)) .map(c => libloki.api.createGroupSyncMessage(c))
.map(syncMessage => .map(syncMessage =>
libsession libsession.getMessageQueue().sendSyncMessage(syncMessage)
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, syncMessage)
); );
return Promise.all(syncPromises); return Promise.all(syncPromises);
@ -458,12 +449,7 @@ MessageSender.prototype = {
openGroupsSyncParams openGroupsSyncParams
); );
const pubKey = textsecure.storage.user.getNumber(); return libsession.getMessageQueue().sendSyncMessage(openGroupsSyncMessage);
const currentPubKey = new libsession.Types.PubKey(pubKey);
return libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, openGroupsSyncMessage);
}, },
syncReadMessages(reads) { syncReadMessages(reads) {
const myDevice = textsecure.storage.user.getDeviceId(); const myDevice = textsecure.storage.user.getDeviceId();
@ -474,11 +460,7 @@ MessageSender.prototype = {
readMessages: reads, readMessages: reads,
} }
); );
const pubKey = textsecure.storage.user.getNumber(); return libsession.getMessageQueue().sendSyncMessage(syncReadMessages);
const currentPubKey = new libsession.Types.PubKey(pubKey);
return libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, syncReadMessages);
} }
return Promise.resolve(); return Promise.resolve();
@ -510,26 +492,8 @@ MessageSender.prototype = {
const verifiedSyncMessage = new window.libsession.Messages.Outgoing.VerifiedSyncMessage( const verifiedSyncMessage = new window.libsession.Messages.Outgoing.VerifiedSyncMessage(
verifiedSyncParams verifiedSyncParams
); );
const pubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(pubKey); return libsession.getMessageQueue().sendSyncMessage(verifiedSyncMessage);
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;
}
}, },
makeProxiedRequest(url, options) { makeProxiedRequest(url, options) {

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

Loading…
Cancel
Save