Update sendSyncMessage to use primary pubkey and don't send to itsself, don't send typing messages for primary conversation (note to self)

pull/601/head
Beaudan Brown 6 years ago
parent 09da4af2df
commit 4aaa9ba26d

@ -1,4 +1,4 @@
/* global _, textsecure, WebAPI, libsignal, OutgoingMessage, window */ /* global _, textsecure, WebAPI, libsignal, OutgoingMessage, window, libloki */
/* eslint-disable more/no-then, no-bitwise */ /* eslint-disable more/no-then, no-bitwise */
@ -434,7 +434,7 @@ MessageSender.prototype = {
return syncMessage; return syncMessage;
}, },
sendSyncMessage( async sendSyncMessage(
encodedDataMessage, encodedDataMessage,
timestamp, timestamp,
destination, destination,
@ -443,9 +443,15 @@ MessageSender.prototype = {
unidentifiedDeliveries = [], unidentifiedDeliveries = [],
options options
) { ) {
const myNumber = textsecure.storage.user.getNumber(); const primaryDeviceKey =
const myDevice = textsecure.storage.user.getDeviceId(); window.storage.get('primaryDevicePubKey') ||
if (myDevice === 1 || myDevice === '1') { textsecure.storage.user.getNumber();
const allOurDevices = (await libloki.storage.getAllDevicePubKeysForPrimaryPubKey(
primaryDeviceKey
))
// Don't send to ourselves
.filter(pubKey => pubKey !== textsecure.storage.user.getNumber());
if (allOurDevices.length === 0) {
return Promise.resolve(); return Promise.resolve();
} }
@ -489,7 +495,7 @@ MessageSender.prototype = {
const silent = true; const silent = true;
return this.sendIndividualProto( return this.sendIndividualProto(
myNumber, primaryDeviceKey,
contentMessage, contentMessage,
Date.now(), Date.now(),
silent, silent,
@ -588,7 +594,8 @@ MessageSender.prototype = {
// We don't want to send typing messages to our other devices, but we will // We don't want to send typing messages to our other devices, but we will
// in the group case. // in the group case.
const myNumber = textsecure.storage.user.getNumber(); const myNumber = textsecure.storage.user.getNumber();
if (recipientId && myNumber === recipientId) { const primaryDevicePubkey = window.storage.get('primaryDevicePubKey');
if (recipientId && primaryDevicePubkey === recipientId) {
return null; return null;
} }

Loading…
Cancel
Save