pull/1137/head
Mikunj 5 years ago
parent df44e5afca
commit 8512c2307b

@ -420,14 +420,16 @@
} }
const devicePubKey = this.get('conversationId'); const devicePubKey = this.get('conversationId');
const otherDevices = await libloki.storage.getPairedDevicesFor(devicePubKey); const otherDevices = await libloki.storage.getPairedDevicesFor(
devicePubKey
);
const allDevices = [devicePubKey, ...otherDevices]; const allDevices = [devicePubKey, ...otherDevices];
// Set profile name to primary conversation // Set profile name to primary conversation
let profileName; let profileName;
const allConversationsWithUser = allDevices.map(d => const allConversationsWithUser = allDevices
ConversationController.get(d) .map(d => ConversationController.get(d))
).filter(c => Boolean(c)); .filter(c => Boolean(c));
allConversationsWithUser.forEach(conversation => { allConversationsWithUser.forEach(conversation => {
// If we somehow received an old friend request (e.g. after having restored // If we somehow received an old friend request (e.g. after having restored
// from seed, we won't be able to accept it, we should initiate our own // from seed, we won't be able to accept it, we should initiate our own
@ -445,7 +447,9 @@
// If you don't have a profile name for this device, and profileName is set, // If you don't have a profile name for this device, and profileName is set,
// add profileName to conversation. // add profileName to conversation.
const primaryDevicePubKey = (await libloki.storage.getPrimaryDeviceFor(devicePubKey)) || devicePubKey; const primaryDevicePubKey =
(await libloki.storage.getPrimaryDeviceFor(devicePubKey)) ||
devicePubKey;
const primaryConversation = allConversationsWithUser.find( const primaryConversation = allConversationsWithUser.find(
c => c.id === primaryDevicePubKey c => c.id === primaryDevicePubKey
); );
@ -477,11 +481,13 @@
}); });
const devicePubKey = this.attributes.conversationId; const devicePubKey = this.attributes.conversationId;
const otherDevices = await libloki.storage.getPairedDevicesFor(devicePubKey); const otherDevices = await libloki.storage.getPairedDevicesFor(
devicePubKey
);
const allDevices = [devicePubKey, ...otherDevices]; const allDevices = [devicePubKey, ...otherDevices];
const allConversationsWithUser = allDevices.map(d => const allConversationsWithUser = allDevices
ConversationController.get(d) .map(d => ConversationController.get(d))
).filter(c => Boolean(c)); .filter(c => Boolean(c));
allConversationsWithUser.forEach(conversation => { allConversationsWithUser.forEach(conversation => {
conversation.onDeclineFriendRequest(); conversation.onDeclineFriendRequest();
}); });

@ -215,11 +215,7 @@ OutgoingMessage.prototype = {
this.errors[this.errors.length] = error; this.errors[this.errors.length] = error;
this.numberCompleted(); this.numberCompleted();
}, },
reloadDevicesAndSend( reloadDevicesAndSend(primaryPubKey, multiDevice = true) {
primaryPubKey,
multiDevice = true,
excludedDevices = []
) {
const ourNumber = textsecure.storage.user.getNumber(); const ourNumber = textsecure.storage.user.getNumber();
if (!multiDevice) { if (!multiDevice) {
@ -235,9 +231,7 @@ OutgoingMessage.prototype = {
.getAllDevicePubKeysForPrimaryPubKey(primaryPubKey) .getAllDevicePubKeysForPrimaryPubKey(primaryPubKey)
// Don't send to ourselves // Don't send to ourselves
.then(devicesPubKeys => .then(devicesPubKeys =>
devicesPubKeys.filter( devicesPubKeys.filter(pubKey => pubKey !== ourNumber)
pubKey => pubKey !== ourNumber && !excludedDevices.includes(pubKey)
)
) )
.then(devicesPubKeys => { .then(devicesPubKeys => {
if (devicesPubKeys.length === 0) { if (devicesPubKeys.length === 0) {
@ -706,18 +700,14 @@ OutgoingMessage.prototype = {
return promise; return promise;
}, },
sendToNumber(number, multiDevice = true, excludedDevices = []) { sendToNumber(number, multiDevice = true) {
let conversation; let conversation;
try { try {
conversation = ConversationController.get(number); conversation = ConversationController.get(number);
} catch (e) { } catch (e) {
// do nothing // do nothing
} }
return this.reloadDevicesAndSend( return this.reloadDevicesAndSend(number, multiDevice).catch(error => {
number,
multiDevice,
excludedDevices
).catch(error => {
conversation.resetPendingSend(); conversation.resetPendingSend();
if (error.message === 'Identity key changed') { if (error.message === 'Identity key changed') {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign

Loading…
Cancel
Save