adress review

pull/1197/head
Audric Ackermann 5 years ago
parent 1650d758a5
commit 8b4e69739d
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

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

@ -1316,13 +1316,9 @@
// Start handle ChatMessages (attachments/quote/preview/body)
// FIXME AUDRIC handle attachments, quote, preview, profileKey
// Special-case the self-send case - we send only a sync message
if (this.isMe()) {
await message.markMessageSyncOnly();
const syncMessage = libsession.Utils.SyncMessageUtils.from(
chatMessage
);
return libsession.getMessageQueue().sendSyncMessage(syncMessage);
// sending is done in the 'private' case below
}
const options = {};
@ -1650,14 +1646,8 @@
};
if (this.isMe()) {
const expirationTimerMessage = new libsession.Messages.Outgoing.ExpirationTimerUpdateMessage(
expireUpdate
);
await message.markMessageSyncOnly();
const syncMessage = libsession.Utils.SyncMessageUtils.from(
expirationTimerMessage
);
return libsession.getMessageQueue().sendSyncMessage(syncMessage);
// sending of the message is handled in the 'private' case below
}
if (this.get('type') === 'private') {

@ -28,8 +28,8 @@
deleteExternalMessageFiles,
getAbsoluteAttachmentPath,
loadAttachmentData,
loadQuoteData,
loadPreviewData,
// loadQuoteData,
// loadPreviewData,
} = window.Signal.Migrations;
const { bytesFromString } = window.Signal.Crypto;
@ -1023,20 +1023,23 @@
const attachmentsWithData = await Promise.all(
(this.get('attachments') || []).map(loadAttachmentData)
);
const { body, attachments } = Whisper.Message.getLongMessageAttachment({
const { body } = Whisper.Message.getLongMessageAttachment({
body: this.get('body'),
attachments: attachmentsWithData,
now: this.get('sent_at'),
});
const quoteWithData = await loadQuoteData(this.get('quote'));
const previewWithData = await loadPreviewData(this.get('preview'));
// TODO add logic for attachments, quote and preview here
// don't blindly reuse the one from loadQuoteData loadPreviewData and getLongMessageAttachment.
// they have similar data structure to the ones we need
// but the main difference is that they haven't been uploaded
// so no url exists in them
// so passing it to chat message is incorrect
// const quoteWithData = await loadQuoteData(this.get('quote'));
// const previewWithData = await loadPreviewData(this.get('preview'));
const chatMessage = new libsession.Messages.Outgoing.ChatMessage({
body,
timestamp: this.get('sent_at'),
attachments,
quote: quoteWithData,
preview: previewWithData,
expireTimer: this.get('expireTimer'),
});
// Special-case the self-send case - we send only a sync message
@ -1044,8 +1047,7 @@
this.trigger('pending');
// FIXME audric add back profileKey
await this.markMessageSyncOnly();
const syncMessage = libsession.Utils.SyncMessageUtils.from(chatMessage);
return libsession.getMessageQueue().sendSyncMessage(syncMessage);
// sending is done in the private case below
}
if (conversation.isPrivate()) {
@ -1103,20 +1105,22 @@
const attachmentsWithData = await Promise.all(
(this.get('attachments') || []).map(loadAttachmentData)
);
const { body, attachments } = Whisper.Message.getLongMessageAttachment({
const { body } = Whisper.Message.getLongMessageAttachment({
body: this.get('body'),
attachments: attachmentsWithData,
now: this.get('sent_at'),
});
const quoteWithData = await loadQuoteData(this.get('quote'));
const previewWithData = await loadPreviewData(this.get('preview'));
// TODO add logic for attachments, quote and preview here
// don't blindly reuse the one from loadQuoteData loadPreviewData and getLongMessageAttachment.
// they have similar data structure to the ones we need
// but the main difference is that they haven't been uploaded
// so no url exists in them
// so passing it to chat message is incorrect
// const quoteWithData = await loadQuoteData(this.get('quote'));
// const previewWithData = await loadPreviewData(this.get('preview'));
const chatMessage = new libsession.Messages.Outgoing.ChatMessage({
body,
timestamp: this.get('sent_at'),
attachments,
quote: quoteWithData,
preview: previewWithData,
expireTimer: this.get('expireTimer'),
});
@ -1124,8 +1128,7 @@
if (number === this.OUR_NUMBER) {
this.trigger('pending');
await this.markMessageSyncOnly();
const syncMessage = libsession.Utils.SyncMessageUtils.from(chatMessage);
return libsession.getMessageQueue().sendSyncMessage(syncMessage);
// sending is done in the private case below
}
const conversation = this.getConversation();
const recipientPubKey = new libsession.Types.PubKey(number);

@ -379,8 +379,14 @@ 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().sendSyncMessage(syncMessage)
libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, syncMessage)
);
return Promise.all(syncPromises);
@ -406,13 +412,17 @@ 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().sendSyncMessage(syncMessage)
libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, syncMessage)
);
return Promise.all(syncPromises);
@ -448,7 +458,12 @@ MessageSender.prototype = {
openGroupsSyncParams
);
return libsession.getMessageQueue().sendSyncMessage(openGroupsSyncMessage);
const pubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(pubKey);
return libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, openGroupsSyncMessage);
},
syncReadMessages(reads) {
const myDevice = textsecure.storage.user.getDeviceId();
@ -459,8 +474,11 @@ MessageSender.prototype = {
readMessages: reads,
}
);
return libsession.getMessageQueue().sendSyncMessage(syncReadMessages);
const pubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(pubKey);
return libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, syncReadMessages);
}
return Promise.resolve();
@ -492,7 +510,13 @@ MessageSender.prototype = {
const verifiedSyncMessage = new window.libsession.Messages.Outgoing.VerifiedSyncMessage(
verifiedSyncParams
);
return libsession.getMessageQueue().sendSyncMessage(verifiedSyncMessage);
const pubKey = textsecure.storage.user.getNumber();
const currentPubKey = new libsession.Types.PubKey(pubKey);
return libsession
.getMessageQueue()
.sendUsingMultiDevice(currentPubKey, verifiedSyncMessage);
},
getOurProfile() {

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

Loading…
Cancel
Save