diff --git a/js/models/conversations.js b/js/models/conversations.js index 17797e4c6..310852c20 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1744,10 +1744,7 @@ await this.setSessionResetStatus(SessionResetEnum.request_received); // send empty message, this will trigger the new session to propagate // to the reset initiator. - window.libloki.api.sendBackgroundMessage( - this.id, - window.textsecure.OutgoingMessage.DebugMessageType.SESSION_RESET_RECV - ); + await window.libloki.api.sendSessionEstablishedMessage(this.id); }, isSessionResetReceived() { @@ -1783,10 +1780,7 @@ async onNewSessionAdopted() { if (this.get('sessionResetStatus') === SessionResetEnum.initiated) { // send empty message to confirm that we have adopted the new session - window.libloki.api.sendBackgroundMessage( - this.id, - window.textsecure.OutgoingMessage.DebugMessageType.SESSION_RESET - ); + await window.libloki.api.sendSessionEstablishedMessage(this.id); } await this.createAndStoreEndSessionMessage({ type: 'incoming', diff --git a/libloki/api.js b/libloki/api.js index f820421af..6c831a3a3 100644 --- a/libloki/api.js +++ b/libloki/api.js @@ -62,14 +62,6 @@ ); await libsession.getMessageQueue().send(user, sessionEstablished); } - - async function sendBackgroundMessage(pubKey, debugMessageType) { - const backgroundMessage = textsecure.OutgoingMessage.buildBackgroundMessage( - pubKey, - debugMessageType - ); - await backgroundMessage.sendToNumber(pubKey, false); - } // Serialise as ... // This is an implementation of the reciprocal of contacts_parser.js function serialiseByteBuffers(buffers) { @@ -213,7 +205,6 @@ window.libloki.api = { sendSessionEstablishedMessage, - sendBackgroundMessage, sendSessionRequestsToMembers, createContactSyncProtoMessage, createGroupSyncProtoMessage, diff --git a/libloki/test/messages.js b/libloki/test/messages.js deleted file mode 100644 index ff2ed3c4a..000000000 --- a/libloki/test/messages.js +++ /dev/null @@ -1,46 +0,0 @@ -/* global assert */ - -describe('Loki Messages', () => { - describe('#backgroundMessage', () => { - it('structure is valid', () => { - const pubkey = - '05050505050505050505050505050505050505050505050505050505050505050'; - const backgroundMessage = window.textsecure.OutgoingMessage.buildBackgroundMessage( - pubkey - ); - - const validBackgroundObject = { - server: null, - numbers: [pubkey], - // For now, a background message contains only a loki address message as - // it must not be an empty message for android - }; - - const validBgMessage = { - dataMessage: null, - syncMessage: null, - callMessage: null, - nullMessage: null, - receiptMessage: null, - typingMessage: null, - preKeyBundleMessage: null, - pairingAuthorisation: null, - }; - - const lokiAddressMessage = { - p2pAddress: null, - p2pPort: null, - type: 1, - }; - - assert.isNumber(backgroundMessage.timestamp); - assert.isFunction(backgroundMessage.callback); - assert.deepInclude(backgroundMessage, validBackgroundObject); - assert.deepInclude(backgroundMessage.message, validBgMessage); - assert.deepInclude( - backgroundMessage.message.lokiAddressMessage, - lokiAddressMessage - ); - }); - }); -}); diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index 0c13e9d2e..3b229714b 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -671,57 +671,6 @@ OutgoingMessage.buildSessionRequestMessage = function buildSessionRequestMessage ); }; -OutgoingMessage.buildSessionEstablishedMessage = pubKey => { - const nullMessage = new textsecure.protobuf.NullMessage(); - const content = new textsecure.protobuf.Content({ - nullMessage, - }); - - // The below message type will ignore auto FR - const options = { messageType: 'onlineBroadcast' }; - return new textsecure.OutgoingMessage( - null, // server - Date.now(), // timestamp, - [pubKey], // numbers - content, // message - true, // silent - () => null, // callback - options - ); -}; - -OutgoingMessage.buildBackgroundMessage = function buildBackgroundMessage( - pubKey, - debugMessageType -) { - const p2pAddress = null; - const p2pPort = null; - // We result loki address message for sending "background" messages - const type = textsecure.protobuf.LokiAddressMessage.Type.HOST_UNREACHABLE; - - // This is needed even if LokiAddressMessage shouldn't be used. - // looks like the message is not sent or dropped on reception - // if the content is completely empty - const lokiAddressMessage = new textsecure.protobuf.LokiAddressMessage({ - p2pAddress, - p2pPort, - type, - }); - const content = new textsecure.protobuf.Content({ lokiAddressMessage }); - - const options = { messageType: 'onlineBroadcast', debugMessageType }; - // Send a empty message with information about how to contact us directly - return new OutgoingMessage( - null, // server - Date.now(), // timestamp, - [pubKey], // numbers - content, // message - true, // silent - () => null, // callback - options - ); -}; - OutgoingMessage.DebugMessageType = DebugMessageType; window.textsecure = window.textsecure || {};