diff --git a/js/models/conversations.js b/js/models/conversations.js index 11a209730..515f0d9d4 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -994,21 +994,15 @@ ConversationController.get(d) ); - const pendingRequests = await allConversationsWithUser.reduce( - async (requestsP, conversation) => { - const requests = await requestsP; - const request = (await conversation.getFriendRequests( - direction, - status - ))[0]; - - return request - ? requests.concat({ conversation, request }) - : requests; - }, - [] - ); + const pendingRequestPromises = allConversationsWithUser.map(c => + c.getFriendRequests(direction, status) + )[0]; + + let pendingRequests = await Promise.all(pendingRequestPromises); + pendingRequests = pendingRequests.filter(p => Boolean(p.length)); + // We set all friend request messages from all devices + // from a user here to accepted where possible await Promise.all( pendingRequests.map(async friendRequest => { const { conversation, request } = friendRequest; diff --git a/js/models/messages.js b/js/models/messages.js index 4fe21e55a..7a6dfb207 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -425,6 +425,7 @@ primaryDevicePubKey ); + // Set profile name to primary conversation let profileName; const allConversationsWithUser = allDevices.map(d => ConversationController.get(d) @@ -458,6 +459,13 @@ }); this.set({ friendStatus: 'accepted' }); + + // Update redux store + window.Signal.Data.updateConversation( + primaryConversation.id, + primaryConversation.attributes, + { Conversation: Whisper.Conversation } + ); }, async declineFriendRequest() { if (this.get('friendStatus') !== 'pending') { diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 8f62cf34a..de913df47 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1045,45 +1045,6 @@ MessageReceiver.prototype.extend({ return this.handlePairingRequest(envelope, pairingAuthorisation); }, - async handleSecondaryDeviceFriendRequest(pubKey, deviceMapping) { - if (!deviceMapping) { - return false; - } - // Only handle secondary pubkeys - if (deviceMapping.isPrimary === '1' || !deviceMapping.authorisations) { - return false; - } - const { authorisations } = deviceMapping; - // Secondary devices should only have 1 authorisation from a primary device - if (authorisations.length !== 1) { - return false; - } - const authorisation = authorisations[0]; - if (!authorisation) { - return false; - } - if (!authorisation.grantSignature) { - return false; - } - const isValid = await libloki.crypto.validateAuthorisation(authorisation); - if (!isValid) { - return false; - } - const correctSender = pubKey === authorisation.secondaryDevicePubKey; - if (!correctSender) { - return false; - } - const { primaryDevicePubKey } = authorisation; - // ensure the primary device is a friend - const c = window.ConversationController.get(primaryDevicePubKey); - if (!c || (await !c.isFriendWithAnyDevice())) { - return false; - } - await libloki.storage.savePairingAuthorisation(authorisation); - - return true; - }, - async updateProfile(conversation, profile, profileKey) { // Retain old values unless changed: const newProfile = conversation.get('profile') || {};