Rename blockSync, only send contacts and profile if sending a GRANT request, do *not* always be friends with secondary devices because we still need to complete a friend request exchange

pull/606/head
Beaudan Brown 5 years ago
parent 332cd30052
commit c31535edb4

@ -1244,7 +1244,7 @@
libloki.api.sendBackgroundMessage(conversation.id); libloki.api.sendBackgroundMessage(conversation.id);
} else { } else {
// Accept any pending friend requests if there are any // Accept any pending friend requests if there are any
conversation.onAcceptFriendRequest({ fromContactSync: true }); conversation.onAcceptFriendRequest({ blockSync: true });
} }
if (details.profileKey) { if (details.profileKey) {

@ -775,7 +775,7 @@
} }
}, },
async setFriendRequestStatus(newStatus, options = {}) { async setFriendRequestStatus(newStatus, options = {}) {
const { fromContactSync } = options; const { blockSync } = options;
// Ensure that the new status is a valid FriendStatusEnum value // Ensure that the new status is a valid FriendStatusEnum value
if (!(newStatus in Object.values(FriendRequestStatusEnum))) { if (!(newStatus in Object.values(FriendRequestStatusEnum))) {
return; return;
@ -792,7 +792,7 @@
Conversation: Whisper.Conversation, Conversation: Whisper.Conversation,
}); });
await this.updateTextInputState(); await this.updateTextInputState();
if (!fromContactSync && newStatus === FriendRequestStatusEnum.friends) { if (!blockSync && newStatus === FriendRequestStatusEnum.friends) {
// Sync contact // Sync contact
this.wrapSend(textsecure.messaging.sendContactSyncMessage(this)); this.wrapSend(textsecure.messaging.sendContactSyncMessage(this));
} }

@ -165,14 +165,11 @@
ourNumber, ourNumber,
'private' 'private'
); );
const secondaryConversation = await ConversationController.getOrCreateAndWait( const content = new textsecure.protobuf.Content({
recipientPubKey, pairingAuthorisation,
'private' });
); const isGrant = authorisation.primaryDevicePubKey === ourNumber;
// Always be friends with secondary devices if (isGrant) {
secondaryConversation.setFriendRequestStatus(
window.friends.friendRequestStatusEnum.friends
);
// Send profile name to secondary device // Send profile name to secondary device
const lokiProfile = ourConversation.getLokiProfile(); const lokiProfile = ourConversation.getLokiProfile();
const profile = new textsecure.protobuf.DataMessage.LokiProfile( const profile = new textsecure.protobuf.DataMessage.LokiProfile(
@ -187,11 +184,9 @@
{ ConversationCollection: Whisper.ConversationCollection } { ConversationCollection: Whisper.ConversationCollection }
); );
const syncMessage = await createContactSyncProtoMessage(conversations); const syncMessage = await createContactSyncProtoMessage(conversations);
const content = new textsecure.protobuf.Content({ content.syncMessage = syncMessage;
pairingAuthorisation, content.dataMessage = dataMessage;
dataMessage, }
syncMessage,
});
// Send // Send
const options = { messageType: 'pairing-request' }; const options = { messageType: 'pairing-request' };
const p = new Promise((resolve, reject) => { const p = new Promise((resolve, reject) => {

@ -1232,8 +1232,6 @@ MessageReceiver.prototype.extend({
return false; return false;
} }
await libloki.storage.savePairingAuthorisation(authorisation); await libloki.storage.savePairingAuthorisation(authorisation);
// sending a message back = accepting friend request
window.libloki.api.sendBackgroundMessage(pubKey);
return true; return true;
}, },
@ -1293,7 +1291,12 @@ MessageReceiver.prototype.extend({
deviceMapping deviceMapping
); );
if (autoAccepted) { if (autoAccepted) {
await conversation.onFriendRequestAccepted(); // sending a message back = accepting friend request
// Directly setting friend request status to skip the pending state
await conversation.setFriendRequestStatus(
window.friends.friendRequestStatusEnum.friends
);
window.libloki.api.sendBackgroundMessage(envelope.source);
return this.removeFromCache(envelope); return this.removeFromCache(envelope);
} }
} }

Loading…
Cancel
Save