From f1c155b9439260b0943845296342015f27640d6e Mon Sep 17 00:00:00 2001 From: Beaudan Brown Date: Fri, 15 Nov 2019 09:31:38 +1100 Subject: [PATCH] Stop sending sync messages to public chats and mark messages from any of our devices as outgoing --- js/background.js | 5 +++-- js/models/messages.js | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/background.js b/js/background.js index ffa504b4b..2b3cdd05f 100644 --- a/js/background.js +++ b/js/background.js @@ -1441,7 +1441,8 @@ return handleProfileUpdate({ data, confirm, messageDescriptor }); } - const ourNumber = textsecure.storage.user.getNumber(); + const primaryDeviceKey = window.storage.get('primaryDevicePubKey'); + const allOurDevices = await libloki.storage.getAllDevicePubKeysForPrimaryPubKey(primaryDeviceKey); const descriptorId = await textsecure.MessageReceiver.arrayBufferToString( messageDescriptor.id ); @@ -1449,7 +1450,7 @@ if ( messageDescriptor.type === 'group' && descriptorId.match(/^publicChat:/) && - data.source === ourNumber + allOurDevices.includes(data.source) ) { // Public chat messages from ourselves should be outgoing message = await createSentMessage(data); diff --git a/js/models/messages.js b/js/models/messages.js index 243481218..32a9904ba 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -1270,7 +1270,11 @@ this.trigger('sent', this); if (this.get('type') !== 'friend-request') { - this.sendSyncMessage(); + const c = this.getConversation(); + // Don't bother sending sync messages to public chats + if (!c.isPublic()) { + this.sendSyncMessage(); + } } }) .catch(result => {