|
|
|
@ -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) {
|
|
|
|
|