From 81ddd734d442f03bba3bcf4022e01f761e6b9209 Mon Sep 17 00:00:00 2001 From: Jean Brito Date: Wed, 26 Apr 2023 16:36:57 -0300 Subject: [PATCH 1/2] use electron-builder information to validate deeplinks --- package.json | 1 + src/app/main/app.ts | 1 + src/deepLinks/main.ts | 17 +++++++++++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index bf55535ad8..7b59c72760 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "copyright": "© 2016-2021, Rocket.Chat", "homepage": "https://rocket.chat", "license": "MIT", + "goUrlShortener": "go.rocket.chat", "keywords": [ "rocketchat", "desktop", diff --git a/src/app/main/app.ts b/src/app/main/app.ts index 3363377ba8..8b97145e8d 100644 --- a/src/app/main/app.ts +++ b/src/app/main/app.ts @@ -22,6 +22,7 @@ import { APP_PATH_SET, APP_VERSION_SET } from '../actions'; export const packageJsonInformation = { productName: packageJson.productName, + goUrlShortener: packageJson.goUrlShortener, }; export const electronBuilderJsonInformation = { diff --git a/src/deepLinks/main.ts b/src/deepLinks/main.ts index 9182e229fc..73bb61980f 100644 --- a/src/deepLinks/main.ts +++ b/src/deepLinks/main.ts @@ -2,6 +2,10 @@ import { URL } from 'url'; import { app, WebContents } from 'electron'; +import { + electronBuilderJsonInformation, + packageJsonInformation, +} from '../app/main/app'; import { ServerUrlResolutionStatus } from '../servers/common'; import { resolveServerUrl } from '../servers/main'; import { select, dispatch } from '../store'; @@ -13,11 +17,12 @@ import { getRootWindow } from '../ui/main/rootWindow'; import { getWebContentsByServerUrl } from '../ui/main/serverView'; import { DEEP_LINKS_SERVER_FOCUSED, DEEP_LINKS_SERVER_ADDED } from './actions'; -const isRocketChatUrl = (parsedUrl: URL): boolean => - parsedUrl.protocol === 'rocketchat:'; +const isDefinedProtocol = (parsedUrl: URL): boolean => + parsedUrl.protocol === `${electronBuilderJsonInformation.protocol}:`; -const isGoRocketChatUrl = (parsedUrl: URL): boolean => - parsedUrl.protocol === 'https:' && parsedUrl.hostname === 'go.rocket.chat'; +const isGoUrlShortener = (parsedUrl: URL): boolean => + parsedUrl.protocol === 'https:' && + parsedUrl.hostname === packageJsonInformation.goUrlShortener; const parseDeepLink = ( input: string @@ -35,13 +40,13 @@ const parseDeepLink = ( return null; } - if (isRocketChatUrl(url)) { + if (isDefinedProtocol(url)) { const action = url.hostname; const args = url.searchParams; return { action, args }; } - if (isGoRocketChatUrl(url)) { + if (isGoUrlShortener(url)) { const action = url.pathname; const args = url.searchParams; return { action, args }; From 2b0032d848120bd50bdcb4e14f8536aca4822237 Mon Sep 17 00:00:00 2001 From: Jean Brito Date: Wed, 26 Apr 2023 18:15:52 -0300 Subject: [PATCH 2/2] use product name as video call window name --- src/videoCallWindow/ipc.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/videoCallWindow/ipc.ts b/src/videoCallWindow/ipc.ts index 808b37f092..28ddd3312d 100644 --- a/src/videoCallWindow/ipc.ts +++ b/src/videoCallWindow/ipc.ts @@ -10,6 +10,7 @@ import { systemPreferences, } from 'electron'; +import { packageJsonInformation } from '../app/main/app'; import { handle } from '../ipc/main'; import { getRootWindow } from '../ui/main/rootWindow'; @@ -29,7 +30,6 @@ export const startVideoCallWindowHandler = (): void => { ); handle('video-call-window/open-window', async (_event, url) => { - console.log('[Rocket.Chat Desktop] open-internal-video-chat-window', url); const validUrl = new URL(url); const allowedProtocols = ['http:', 'https:']; if (allowedProtocols.includes(validUrl.protocol)) { @@ -83,8 +83,9 @@ export const startVideoCallWindowHandler = (): void => { videoCallWindow.loadFile( path.join(app.getAppPath(), 'app/video-call-window.html') ); + videoCallWindow.once('ready-to-show', () => { - console.log('[Rocket.Chat Desktop] ready-to-show', url); + videoCallWindow.setTitle(packageJsonInformation.productName); videoCallWindow.webContents.send('video-call-window/open-url', url); videoCallWindow.show(); });