diff --git a/js/models/conversations.js b/js/models/conversations.js index 1cebf227a..07a684be9 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -498,14 +498,19 @@ this.updateTextInputState(); const friendRequestStatus = this.getFriendRequestStatus(); - friendRequestStatus.allowSending = true; - this.set({ friendRequestStatus }); + if (friendRequestStatus) { + friendRequestStatus.allowSending = true; + this.set({ friendRequestStatus }); - await window.Signal.Data.updateConversation(this.id, this.attributes, { - Conversation: Whisper.Conversation, - }); + await window.Signal.Data.updateConversation(this.id, this.attributes, { + Conversation: Whisper.Conversation, + }); + } }, async onFriendRequestSent() { + // Don't bother setting the friend request if we have already exchanged keys + if (this.isKeyExchangeCompleted()) return; + const friendRequestLockDuration = 72; // hours let friendRequestStatus = this.getFriendRequestStatus(); @@ -1102,7 +1107,7 @@ this.trigger('disable:input', true); this.trigger('change:placeholder', 'disabled'); return; - } else if (outgoing.length > 0) { + } else { // Tell the user to introduce themselves this.trigger('disable:input', false); this.trigger('change:placeholder', 'friend-request'); diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index c61af47df..4206591a2 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -964,7 +964,8 @@ MessageReceiver.prototype.extend({ message.preKeyBundle ); } - + + await conversation.onFriendRequestAccepted(); } console.log(`Friend request for ${pubKey} was ${message.friendStatus}`, message); },