From 00b57c7983d91ae8fdfcd13e443e33cfb800eead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 13 Nov 2019 15:07:40 +0100 Subject: [PATCH] fix(transport): remove legacy code It has been around bor > 2.5 years already. --- .../transport/PostMessageTransportBackend.js | 99 +------------------ modules/transport/index.js | 7 +- 2 files changed, 2 insertions(+), 104 deletions(-) diff --git a/modules/transport/PostMessageTransportBackend.js b/modules/transport/PostMessageTransportBackend.js index 1caa65beb..f1435952b 100644 --- a/modules/transport/PostMessageTransportBackend.js +++ b/modules/transport/PostMessageTransportBackend.js @@ -9,43 +9,6 @@ const DEFAULT_POSTIS_OPTIONS = { window: window.opener || window.parent }; -/** - * The list of methods of incoming postis messages that we have to support for - * backward compatibility for the users that are directly sending messages to - * Jitsi Meet (without using external_api.js) - * - * @type {string[]} - */ -const LEGACY_INCOMING_METHODS = [ - 'avatar-url', - 'display-name', - 'email', - 'toggle-audio', - 'toggle-chat', - 'toggle-film-strip', - 'toggle-share-screen', - 'toggle-video', - 'video-hangup' -]; - -/** - * The list of methods of outgoing postis messages that we have to support for - * backward compatibility for the users that are directly listening to the - * postis messages send by Jitsi Meet(without using external_api.js). - * - * @type {string[]} - */ -const LEGACY_OUTGOING_METHODS = [ - 'display-name-change', - 'incoming-message', - 'outgoing-message', - 'participant-joined', - 'participant-left', - 'video-conference-joined', - 'video-conference-left', - 'video-ready-to-close' -]; - /** * The postis method used for all messages. * @@ -63,34 +26,13 @@ export default class PostMessageTransportBackend { * @param {Object} options - Optional parameters for configuration of the * transport. */ - constructor({ enableLegacyFormat, postisOptions } = {}) { + constructor({ postisOptions } = {}) { // eslint-disable-next-line new-cap this.postis = Postis({ ...DEFAULT_POSTIS_OPTIONS, ...postisOptions }); - /** - * If true PostMessageTransportBackend will process and send messages - * using the legacy format and in the same time the current format. - * Otherwise all messages (outgoing and incoming) that are using the - * legacy format will be ignored. - * - * @type {boolean} - */ - this._enableLegacyFormat = enableLegacyFormat; - - if (this._enableLegacyFormat) { - // backward compatibility - LEGACY_INCOMING_METHODS.forEach(method => - this.postis.listen( - method, - params => - this._legacyMessageReceivedCallback(method, params) - ) - ); - } - this._receiveCallback = () => { // Do nothing until a callback is set by the consumer of // PostMessageTransportBackend via setReceiveCallback. @@ -101,37 +43,6 @@ export default class PostMessageTransportBackend { message => this._receiveCallback(message)); } - /** - * Handles incoming legacy postis messages. - * - * @param {string} method - The method property from the postis message. - * @param {Any} params - The params property from the postis message. - * @returns {void} - */ - _legacyMessageReceivedCallback(method, params = {}) { - this._receiveCallback({ - data: { - name: method, - data: params - } - }); - } - - /** - * Sends the passed message via postis using the old format. - * - * @param {Object} legacyMessage - The message to be sent. - * @returns {void} - */ - _sendLegacyMessage({ name, ...data }) { - if (name && LEGACY_OUTGOING_METHODS.indexOf(name) !== -1) { - this.postis.send({ - method: name, - params: data - }); - } - } - /** * Disposes the allocated resources. * @@ -152,14 +63,6 @@ export default class PostMessageTransportBackend { method: POSTIS_METHOD_NAME, params: message }); - - if (this._enableLegacyFormat) { - // For the legacy use case we don't need any new fields defined in - // Transport class. That's why we are passing only the original - // object passed by the consumer of the Transport class which is - // message.data. - this._sendLegacyMessage(message.data || {}); - } } /** diff --git a/modules/transport/index.js b/modules/transport/index.js index 1aa712b97..fc67c1f40 100644 --- a/modules/transport/index.js +++ b/modules/transport/index.js @@ -36,12 +36,7 @@ let transport; */ export function getJitsiMeetTransport() { if (!transport) { - transport = new Transport({ - backend: new PostMessageTransportBackend({ - enableLegacyFormat: true, - postisOptions - }) - }); + transport = new Transport({ backend: new PostMessageTransportBackend({ postisOptions }) }); } return transport;