From 63c6f12a663a85333b1dda9134e65ba2683305fb Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 1 Jul 2020 11:55:51 +1000 Subject: [PATCH] send sync message when a message was sent to someone --- js/models/conversations.js | 2 -- js/models/messages.js | 5 ----- js/views/inbox_view.js | 17 ++++++++++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 09e8b90f1..191562d62 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1279,7 +1279,6 @@ Message: Whisper.Message, }); message.set({ id }); - message.markPendingSend(); this.set({ lastMessage: model.getNotificationText(), @@ -1840,7 +1839,6 @@ const mediumGroupCreateMessage = new libsession.Messages.Outgoing.MediumGroupCreateMessage( createParams ); - message.markPendingSend(); members.forEach(member => { const memberPubKey = new libsession.Types.PubKey(member); diff --git a/js/models/messages.js b/js/models/messages.js index fa7213dee..752efb77c 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -1098,7 +1098,6 @@ // Special-case the self-send case - we send only a sync message if (recipients.length === 1 && recipients[0] === this.OUR_NUMBER) { - this.trigger('pending'); // FIXME audric add back profileKey return this.sendSyncMessageOnly(chatMessage); } @@ -1106,14 +1105,12 @@ if (conversation.isPrivate()) { const [number] = recipients; const recipientPubKey = new libsession.Types.PubKey(number); - this.trigger('pending'); return libsession .getMessageQueue() .sendUsingMultiDevice(recipientPubKey, chatMessage); } - this.trigger('pending'); // TODO should we handle medium groups message here too? // Not sure there is the concept of retrySend for those const closedGroupChatMessage = new libsession.Messages.Outgoing.ClosedGroupChatMessage( @@ -1173,8 +1170,6 @@ quote, }); - this.trigger('pending'); - // Special-case the self-send case - we send only a sync message if (number === this.OUR_NUMBER) { return this.sendSyncMessageOnly(chatMessage); diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index fbd22e6e7..96a343342 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -10,6 +10,7 @@ Whisper, textsecure, Signal, + libsession, _ */ @@ -316,17 +317,21 @@ // Handle the sync logic here if (!isOurDevice && !msg.get('synced') && !msg.get('sentSync')) { - // FIXME audric send the syncMessage - // const contentDecoded = textsecure.protobuf.Content.decode(m.plainTextBuffer); - // const { dataMessage } = contentDecoded; + const contentDecoded = textsecure.protobuf.Content.decode( + m.plainTextBuffer + ); + const { dataMessage } = contentDecoded; + msg.sendSyncMessageOnly(dataMessage); msg.set({ sentSync: true }); } else if (isOurDevice && msg.get('sentSync')) { msg.set({ synced: true }); } - + const primaryPubKey = await libsession.Protocols.MultiDeviceProtocol.getPrimaryDevice( + m.device + ); msg.set({ - sent_to: _.union(sentTo, [m.device]), + sent_to: _.union(sentTo, [primaryPubKey.key]), sent: true, expirationStartTimestamp: Date.now(), // unidentifiedDeliveries: result.unidentifiedDeliveries, @@ -355,8 +360,6 @@ await c.getProfiles(); } } - // if (result.successfulNumbers.length > 0) { - // const sentTo = this.get('sent_to') || []; const expirationStartTimestamp = Date.now(); if (