From f7971f70268b1beee63bce1ce53b5af8b6180116 Mon Sep 17 00:00:00 2001 From: AlphaX-Qortal Date: Wed, 12 Feb 2025 22:26:49 +0100 Subject: [PATCH] Change protocol check --- plugins/plugins/core/components/ChatPage.js | 12 ++++-------- plugins/plugins/core/streams/onNewBlock.js | 6 ++++-- plugins/plugins/core/streams/streams.js | 3 ++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/plugins/plugins/core/components/ChatPage.js b/plugins/plugins/core/components/ChatPage.js index 2e2406b1..fc84eeaa 100644 --- a/plugins/plugins/core/components/ChatPage.js +++ b/plugins/plugins/core/components/ChatPage.js @@ -2551,15 +2551,13 @@ class ChatPage extends LitElement { const initDirect = async (cid, noInitial) => { let timeoutId let initial = 0 - let directSocketTimeout - let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] let nodeUrl = myNode.domain + ":" + myNode.port - + let nodeProtocol = myNode.protocol let directSocketLink - if (window.parent.location.protocol === "https:") { + if (nodeProtocol === "https") { directSocketLink = `wss://${nodeUrl}/websockets/chat/messages?involving=${window.parent.reduxStore.getState().app.selectedAddress.address}&involving=${cid}&encoding=BASE64&limit=1` } else { // Fallback to http @@ -2675,17 +2673,15 @@ class ChatPage extends LitElement { const initGroup = (gId, noInitial) => { let timeoutId let groupId = Number(gId) - let initial = 0 let count = 0 let groupSocketTimeout - let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] let nodeUrl = myNode.domain + ":" + myNode.port - + let nodeProtocol = myNode.protocol let groupSocketLink - if (window.parent.location.protocol === "https:") { + if (nodeProtocol === "https") { groupSocketLink = `wss://${nodeUrl}/websockets/chat/messages?txGroupId=${groupId}&encoding=BASE64&limit=1` } else { // Fallback to http diff --git a/plugins/plugins/core/streams/onNewBlock.js b/plugins/plugins/core/streams/onNewBlock.js index dda6e70f..a0e6efc2 100644 --- a/plugins/plugins/core/streams/onNewBlock.js +++ b/plugins/plugins/core/streams/onNewBlock.js @@ -136,9 +136,10 @@ function attemptReconnectNodeStatusSocket() { const initBlockSocket = () => { let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] let nodeUrl = myNode.domain + ":" + myNode.port + let nodeProtocol = myNode.protocol let activeBlockSocketLink - if (window.parent.location.protocol === "https:") { + if (nodeProtocol === "https") { activeBlockSocketLink = `wss://${nodeUrl}/websockets/blocks` } else { activeBlockSocketLink = `ws://${nodeUrl}/websockets/blocks` @@ -205,9 +206,10 @@ const pingactiveBlockSocket = () => { const initNodeStatusSocket = () => { let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] let nodeUrl = myNode.domain + ":" + myNode.port + let nodeProtocol = myNode.protocol let activeNodeStatusSocketLink - if (window.parent.location.protocol === "https:") { + if (nodeProtocol === "https") { activeNodeStatusSocketLink = `wss://${nodeUrl}/websockets/admin/status` } else { activeNodeStatusSocketLink = `ws://${nodeUrl}/websockets/admin/status` diff --git a/plugins/plugins/core/streams/streams.js b/plugins/plugins/core/streams/streams.js index 30a5ea3f..23b8d414 100644 --- a/plugins/plugins/core/streams/streams.js +++ b/plugins/plugins/core/streams/streams.js @@ -112,9 +112,10 @@ parentEpml.subscribe('logged_in', async isLoggedIn => { const initChatHeadSocket = () => { let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] let nodeUrl = myNode.domain + ":" + myNode.port + let nodeProtocol = myNode.protocol let activeChatSocketLink - if (window.parent.location.protocol === "https:") { + if (nodeProtocol === "https") { activeChatSocketLink = `wss://${nodeUrl}/websockets/chat/active/${window.parent.reduxStore.getState().app.selectedAddress.address}?encoding=BASE64` } else { activeChatSocketLink = `ws://${nodeUrl}/websockets/chat/active/${window.parent.reduxStore.getState().app.selectedAddress.address}?encoding=BASE64`