diff --git a/js/models/conversations.js b/js/models/conversations.js index 5b0592222..bdbc2c760 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1775,7 +1775,12 @@ await this.setSessionResetStatus(SessionResetEnum.request_received); // send empty message, this will trigger the new session to propagate // to the reset initiator. - await window.libloki.api.sendSessionEstablishedMessage(this.id); + const user = new libsession.Types.PubKey(this.id); + + const sessionEstablished = new window.libsession.Messages.Outgoing.SessionEstablishedMessage( + { timestamp: Date.now() } + ); + await libsession.getMessageQueue().send(user, sessionEstablished); }, isSessionResetReceived() { @@ -1811,7 +1816,13 @@ async onNewSessionAdopted() { if (this.get('sessionResetStatus') === SessionResetEnum.initiated) { // send empty message to confirm that we have adopted the new session - await window.libloki.api.sendSessionEstablishedMessage(this.id); + const user = new libsession.Types.PubKey(this.id); + + const sessionEstablished = new window.libsession.Messages.Outgoing.SessionEstablishedMessage( + { timestamp: Date.now() } + ); + await libsession.getMessageQueue().send(user, sessionEstablished); + } await this.createAndStoreEndSessionMessage({ type: 'incoming', diff --git a/libloki/api.js b/libloki/api.js index 6b6ceb214..84dcb5b40 100644 --- a/libloki/api.js +++ b/libloki/api.js @@ -54,14 +54,6 @@ } } - async function sendSessionEstablishedMessage(pubKey) { - const user = new libsession.Types.PubKey(pubKey); - - const sessionEstablished = new window.libsession.Messages.Outgoing.SessionEstablishedMessage( - { timestamp: Date.now() } - ); - await libsession.getMessageQueue().send(user, sessionEstablished); - } // Serialise as ... // This is an implementation of the reciprocal of contacts_parser.js function serialiseByteBuffers(buffers) { @@ -166,7 +158,6 @@ }; window.libloki.api = { - sendSessionEstablishedMessage, sendSessionRequestsToMembers, createContactSyncMessage, createGroupSyncMessage, diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index c1ff33437..7c0b48aba 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1144,7 +1144,12 @@ MessageReceiver.prototype.extend({ ); window.log.debug('sending session established to', envelope.source); // We don't need to await the call below because we just want to send it off - window.libloki.api.sendSessionEstablishedMessage(envelope.source); + const user = new libsession.Types.PubKey(envelope.source); + + const sessionEstablished = new window.libsession.Messages.Outgoing.SessionEstablishedMessage( + { timestamp: Date.now() } + ); + await libsession.getMessageQueue().send(user, sessionEstablished); } catch (e) { window.log.warn('Failed to process session request', e); // TODO how to handle a failed session request?