From b42bc0527075b0121043bc9623b9e912fe77b49d Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 18 Jun 2020 08:55:54 +1000 Subject: [PATCH] replace unlink message --- js/background.js | 5 ++++- libloki/api.js | 8 -------- libtextsecure/outgoing_message.js | 22 ---------------------- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/js/background.js b/js/background.js index 0ff3d1320..7cbaad953 100644 --- a/js/background.js +++ b/js/background.js @@ -1407,7 +1407,10 @@ ); await window.lokiFileServerAPI.updateOurDeviceMapping(); // TODO: we should ensure the message was sent and retry automatically if not - await libloki.api.sendUnpairingMessageToSecondary(pubKey); + const device = new libsession.Types.PubKey(pubKey); + const unlinkMessage = new libsession.Messages.Outgoing.DeviceUnlinkMessage(pubKey); + + await libsession.messageQueue.send(device, unlinkMessage); // Remove all traces of the device setTimeout(() => { ConversationController.deleteContact(pubKey); diff --git a/libloki/api.js b/libloki/api.js index c0e3cd533..f8c7041bc 100644 --- a/libloki/api.js +++ b/libloki/api.js @@ -70,13 +70,6 @@ ); await backgroundMessage.sendToNumber(pubKey, false); } - - function sendUnpairingMessageToSecondary(pubKey) { - const unpairingMessage = textsecure.OutgoingMessage.buildUnpairingMessage( - pubKey - ); - return unpairingMessage.sendToNumber(pubKey, false); - } // Serialise as ... // This is an implementation of the reciprocal of contacts_parser.js function serialiseByteBuffers(buffers) { @@ -222,7 +215,6 @@ sendSessionEstablishedMessage, sendBackgroundMessage, sendSessionRequestsToMembers, - sendUnpairingMessageToSecondary, createContactSyncProtoMessage, createGroupSyncProtoMessage, createOpenGroupsSyncProtoMessage, diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index a40491639..ed6a5f678 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -723,28 +723,6 @@ OutgoingMessage.buildBackgroundMessage = function buildBackgroundMessage( ); }; -OutgoingMessage.buildUnpairingMessage = function buildUnpairingMessage(pubKey) { - const flags = textsecure.protobuf.DataMessage.Flags.UNPAIRING_REQUEST; - const dataMessage = new textsecure.protobuf.DataMessage({ - flags, - }); - const content = new textsecure.protobuf.Content({ - dataMessage, - }); - const debugMessageType = DebugMessageType.DEVICE_UNPAIRING_SEND; - const options = { messageType: 'device-unpairing', debugMessageType }; - const outgoingMessage = new textsecure.OutgoingMessage( - null, // server - Date.now(), // timestamp, - [pubKey], // numbers - content, // message - true, // silent - () => null, // callback - options - ); - return outgoingMessage; -}; - OutgoingMessage.DebugMessageType = DebugMessageType; window.textsecure = window.textsecure || {};