Simplify auto accept check

pull/590/head
Beaudan Brown 6 years ago
parent 653fd06451
commit e9dc3b531e

@ -927,7 +927,7 @@
messageReceiver.addEventListener('configuration', onConfiguration);
messageReceiver.addEventListener('typing', onTyping);
Whisper.events.on('endSession', (source) => {
Whisper.events.on('endSession', source => {
messageReceiver.handleEndSession(source);
});

@ -1979,16 +1979,17 @@
- We sent the user a friend request and that user sent us a friend request.
- We are friends with the user, and that user just sent us a friend request.
*/
if (
conversation.hasSentFriendRequest() ||
conversation.isFriend()
) {
if (conversation.isFriend()) {
window.Whisper.events.trigger('endSession', source);
}
// Automatically accept incoming friend requests if we have send one already
autoAccept = true;
const isFriend = conversation.isFriend();
const hasSentFriendRequest = conversation.hasSentFriendRequest();
autoAccept = isFriend || hasSentFriendRequest;
if (autoAccept) {
message.set({ friendStatus: 'accepted' });
}
if (isFriend) {
window.Whisper.events.trigger('endSession', source);
} else if (hasSentFriendRequest) {
await conversation.onFriendRequestAccepted();
} else {
await conversation.onFriendRequestReceived();

@ -1663,7 +1663,9 @@ textsecure.MessageReceiver = function MessageReceiverWrapper(
messageReceiver
);
this.getStatus = messageReceiver.getStatus.bind(messageReceiver);
this.handleEndSession = messageReceiver.handleEndSession.bind(messageReceiver);
this.handleEndSession = messageReceiver.handleEndSession.bind(
messageReceiver
);
this.close = messageReceiver.close.bind(messageReceiver);
this.savePreKeyBundleMessage = messageReceiver.savePreKeyBundleMessage.bind(
messageReceiver

Loading…
Cancel
Save