Merge pull request #590 from BeaudanBrown/session-reset-on-fr

Session reset on fr
pull/612/head
Beaudan Campbell-Brown 6 years ago committed by GitHub
commit 6611a10855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1029,6 +1029,10 @@
messageReceiver.addEventListener('configuration', onConfiguration); messageReceiver.addEventListener('configuration', onConfiguration);
messageReceiver.addEventListener('typing', onTyping); messageReceiver.addEventListener('typing', onTyping);
Whisper.events.on('endSession', source => {
messageReceiver.handleEndSession(source);
});
window.Signal.AttachmentDownloads.start({ window.Signal.AttachmentDownloads.start({
getMessageReceiver: () => messageReceiver, getMessageReceiver: () => messageReceiver,
logger: window.log, logger: window.log,

@ -840,7 +840,7 @@
response: 'accepted', response: 'accepted',
status: ['pending', 'expired'], status: ['pending', 'expired'],
}); });
window.libloki.api.sendOnlineBroadcastMessage(this.id); window.libloki.api.sendBackgroundMessage(this.id);
return true; return true;
} }
return false; return false;
@ -1880,7 +1880,7 @@
await this.setSessionResetStatus(SessionResetEnum.request_received); await this.setSessionResetStatus(SessionResetEnum.request_received);
// send empty message, this will trigger the new session to propagate // send empty message, this will trigger the new session to propagate
// to the reset initiator. // to the reset initiator.
await window.libloki.api.sendBackgroundMessage(this.id); window.libloki.api.sendBackgroundMessage(this.id);
}, },
isSessionResetReceived() { isSessionResetReceived() {
@ -1916,7 +1916,7 @@
async onNewSessionAdopted() { async onNewSessionAdopted() {
if (this.get('sessionResetStatus') === SessionResetEnum.initiated) { if (this.get('sessionResetStatus') === SessionResetEnum.initiated) {
// send empty message to confirm that we have adopted the new session // send empty message to confirm that we have adopted the new session
await window.libloki.api.sendBackgroundMessage(this.id); window.libloki.api.sendBackgroundMessage(this.id);
} }
await this.createAndStoreEndSessionMessage({ await this.createAndStoreEndSessionMessage({
type: 'incoming', type: 'incoming',

@ -2175,15 +2175,18 @@
- We sent the user a friend request and that user sent us a friend request. - 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. - We are friends with the user, and that user just sent us a friend request.
*/ */
if ( const isFriend = conversation.isFriend();
conversation.hasSentFriendRequest() || const hasSentFriendRequest = conversation.hasSentFriendRequest();
conversation.isFriend() autoAccept = isFriend || hasSentFriendRequest;
) {
// Automatically accept incoming friend requests if we have send one already if (autoAccept) {
autoAccept = true;
message.set({ friendStatus: 'accepted' }); message.set({ friendStatus: 'accepted' });
}
if (isFriend) {
window.Whisper.events.trigger('endSession', source);
} else if (hasSentFriendRequest) {
await conversation.onFriendRequestAccepted(); await conversation.onFriendRequestAccepted();
window.libloki.api.sendBackgroundMessage(message.get('source'));
} else { } else {
await conversation.onFriendRequestReceived(); await conversation.onFriendRequestReceived();
} }

@ -1479,11 +1479,6 @@ MessageReceiver.prototype.extend({
window.log.error('Error getting conversation: ', number); window.log.error('Error getting conversation: ', number);
} }
// Bail early if a session reset is already ongoing
if (conversation.isSessionResetOngoing()) {
return;
}
await Promise.all( await Promise.all(
deviceIds.map(async deviceId => { deviceIds.map(async deviceId => {
const address = new libsignal.SignalProtocolAddress(number, deviceId); const address = new libsignal.SignalProtocolAddress(number, deviceId);
@ -1669,6 +1664,9 @@ textsecure.MessageReceiver = function MessageReceiverWrapper(
messageReceiver messageReceiver
); );
this.getStatus = messageReceiver.getStatus.bind(messageReceiver); this.getStatus = messageReceiver.getStatus.bind(messageReceiver);
this.handleEndSession = messageReceiver.handleEndSession.bind(
messageReceiver
);
this.close = messageReceiver.close.bind(messageReceiver); this.close = messageReceiver.close.bind(messageReceiver);
this.savePreKeyBundleMessage = messageReceiver.savePreKeyBundleMessage.bind( this.savePreKeyBundleMessage = messageReceiver.savePreKeyBundleMessage.bind(
messageReceiver messageReceiver

Loading…
Cancel
Save