Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supported versions announcement #2732

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e8f4d1c
add unsupported server pane
jeanfbrito Aug 24, 2023
1af7c33
wip
jeanfbrito Aug 29, 2023
d87b986
read file with JWT and load serverInfo
jeanfbrito Aug 31, 2023
96fd388
remove setSupportedVersions from preload
jeanfbrito Aug 31, 2023
5498b42
check if server is supported on webview load
jeanfbrito Aug 31, 2023
13632b9
check server support after load
jeanfbrito Sep 4, 2023
0fc8502
saving decoded supported versions for debug
jeanfbrito Sep 5, 2023
2e92897
create supported version dialog
jeanfbrito Sep 5, 2023
fd4c1a9
show message after some time again
jeanfbrito Sep 8, 2023
53c31c6
only show message when the expiring server is shown
jeanfbrito Sep 8, 2023
b493a76
ignore if there is no expirationMessage
jeanfbrito Sep 8, 2023
e6447c4
improve code organization
jeanfbrito Sep 8, 2023
e8eedba
make translation work with app language
jeanfbrito Sep 8, 2023
6690bbe
add ModalBackDrop
jeanfbrito Sep 8, 2023
239bbe5
use onDismiss
jeanfbrito Sep 12, 2023
713d908
use State component
jeanfbrito Sep 13, 2023
d26272d
add margin to modal
jeanfbrito Sep 13, 2023
6908c56
Merge branch 'master' into lts-support-announcement
jeanfbrito Sep 22, 2023
1934b80
download from cloud on build
jeanfbrito Oct 13, 2023
3718be6
add enforcementStartDate
jeanfbrito Oct 13, 2023
4872ac8
use cloud info
jeanfbrito Oct 16, 2023
ff48b20
fix loading server and other QA things
jeanfbrito Oct 17, 2023
ea05046
make learn more link open on external browser
jeanfbrito Oct 17, 2023
02b6cf7
reactivate not alert before 15 days and on each 12 hours
jeanfbrito Oct 17, 2023
eceb92f
add back expirationMessage title from cloud
jeanfbrito Oct 20, 2023
87149d5
add source of supported versions to config
jeanfbrito Oct 20, 2023
63b5a0a
get back in check only minor version
jeanfbrito Oct 20, 2023
50f7ff1
handle errors on fetching servers
jeanfbrito Oct 23, 2023
f8801b7
fix using cloud info
jeanfbrito Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Thumbs.db
!.yarn/releases
!.yarn/sdks
!.yarn/versions
supportedVersions.jwt
5 changes: 1 addition & 4 deletions electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
"mac": {
"category": "public.app-category.productivity",
"target": [
"dmg",
"pkg",
"zip",
"mas"
"zip"
],
"icon": "build/icon.icns",
"bundleVersion": "118",
Expand Down
22,835 changes: 22,835 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"main": "app/main.js",
"scripts": {
"postinstall": "run-s install-app-deps clean",
"start": "run-s clean build:watch",
"start": "run-s build:watch",
"clean": "rimraf app dist",
"build": "rollup -c",
"build": "yarn build-get-cloud-info && rollup -c ",
"build:watch": "rollup -c -w",
"build-mac": "yarn electron-builder --publish never --mac --universal",
"build-win": "yarn electron-builder --publish never --win",
"build-linux": "yarn electron-builder --publish never --linux",
"build-mac": "yarn build && yarn electron-builder --publish never --mac --universal",
"build-win": "yarn build && yarn electron-builder --publish never --win",
"build-linux": "yarn build && yarn electron-builder --publish never --linux",
"build-assets": "ts-node -O '{\"module\":\"commonjs\"}' src/buildAssets.ts",
"build-assets-win": "ts-node -O \"{\\\"module\\\":\\\"commonjs\\\"}\" src/buildAssets.ts",
"release": "yarn electron-builder --publish onTagOrDraft --x64",
Expand All @@ -45,7 +45,8 @@
".:lint:tsc": "tsc --noEmit --skipLibCheck",
"lint-fix": "run-s .:lint-fix:eslint .:lint:tsc",
".:lint-fix:eslint": "eslint --fix .",
"workspaces:build": "yarn workspaces foreach -t run build"
"workspaces:build": "yarn workspaces foreach -t run build",
"build-get-cloud-info": "ts-node -O \"{\\\"module\\\":\\\"commonjs\\\"}\" src/servers/supportedVersions/downloadFromCloud.ts"
},
"dependencies": {
"@bugsnag/js": "^7.16.0",
Expand All @@ -60,11 +61,14 @@
"@rocket.chat/icons": "^0.32.0-dev.373",
"abort-controller": "^3.0.0",
"axios": "^1.4.0",
"dotenv": "~16.3.1",
"electron-dl": "^3.5.0",
"electron-store": "^8.1.0",
"electron-updater": "^5.3.0",
"ews-javascript-api": "^0.12.0",
"i18next": "^21.6.10",
"jsonwebtoken": "^9.0.1",
"moment": "^2.29.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hook-form": "^7.43.9",
Expand All @@ -74,7 +78,7 @@
"redux": "^4.1.2",
"reselect": "4.1.6",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"semver": "^7.5.4",
"tslib": "^2.3.1"
},
"devDependencies": {
Expand All @@ -97,6 +101,7 @@
"@rollup/plugin-replace": "~3.1.0",
"@types/electron-devtools-installer": "^2.2.1",
"@types/jest": "^27.4.0",
"@types/jsonwebtoken": "^9.0.2",
"@types/meteor": "^2.0.4",
"@types/node": "^17.0.13",
"@types/node-fetch": "^3.0.3",
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
"remember_credentials": "Remember my credentials",
"cancel": " Cancel",
"submit": "Login"
},
"supportedVersion":{
"title": "Workspace version unsupported"
}
},
"downloads": {
Expand Down Expand Up @@ -298,6 +301,11 @@
"announcement": "Houston, we have a problem",
"reload": "Reload"
},
"unsupportedServer": {
"title": "{{workspaceName}} is running an unsupported version of Rocket.Chat",
"announcement": "An admin needs to update this workspace to a supported version in order to restore access from desktop and mobile apps.",
"moreInformation": "Learn more"
},
"selfxss": {
"title": "Stop!",
"description": "This is a browser feature intended for developers. If someone told you to copy-paste something here to enable a Rocket.Chat feature or \"hack\" someone's account, it is a scam and will give them access to your Rocket.Chat account.",
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ const getLng = async (): Promise<keyof typeof resources | undefined> => {
return undefined;
};

export const getLanguage = async (): Promise<string> => {
const lng = await getLng();
if (lng !== undefined) {
return lng;
}
return fallbackLng;
};

class I18nService extends Service {
private async initializeAsync(): Promise<void> {
const lng = await getLng();
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
"dontAskAgain": "Sempre permitir a captura de tela por video chamadas neste servidor",
"yes": "Permitir",
"no": "Cancelar"
},
"supportedVersion":{
"title": "Versão de workspace não suportada"
}
},
"downloads": {
Expand Down
26 changes: 19 additions & 7 deletions src/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const resolveWithExponentialBackoff = <T>(
if (maxRetries === 0) {
throw error;
}

console.log(
'[Rocket.Chat Desktop] Inject resolveWithExponentialBackoff - retrying in 1 seconds'
);
return new Promise<T>((resolve) => {
setTimeout(() => {
resolve(
Expand Down Expand Up @@ -84,18 +86,18 @@ const start = async () => {
: 'meteor/konecty:user-presence';

const settingsModulePath = (() => {
if (versionIsGreaterOrEqualsTo(serverInfo.version, '6.0.0'))
return '/app/settings/client/index.ts';
// if (versionIsGreaterOrEqualsTo(serverInfo.version, '6.0.0'))
// return '/app/settings/client';
if (versionIsGreaterOrEqualsTo(serverInfo.version, '5.0.0'))
return '/app/settings/client';
return '/app/settings/client/index.ts';
return '/app/settings';
})();

const utilsModulePath = (() => {
if (versionIsGreaterOrEqualsTo(serverInfo.version, '6.0.0'))
return '/app/utils/client/index.ts';
// if (versionIsGreaterOrEqualsTo(serverInfo.version, '6.0.0'))
// return '/app/utils/client';
if (versionIsGreaterOrEqualsTo(serverInfo.version, '5.0.0'))
return '/app/utils/client';
return '/app/utils/client/index.ts';
return '/app/utils';
})();

Expand Down Expand Up @@ -123,6 +125,16 @@ const start = async () => {

const open = window.open.bind(window);

Tracker.autorun(() => {
const workspaceUID = settings.get('uniqueID');
if (!workspaceUID) return;
window.RocketChatDesktop.setWorkspaceUID(workspaceUID);
});

Tracker.autorun(() => {
window.RocketChatDesktop.setVersion(serverInfo.version);
});

Tracker.autorun(() => {
const serverMainVersion = serverInfo.version.split('.')[0];

Expand Down
1 change: 1 addition & 0 deletions src/ipc/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type ChannelToArgsMap = {
'certificatesManager/remove': (domain: string) => void;
'server-view/get-url': () => Server['url'] | undefined;
'server-view/ready': () => void;
'server-view/open-url-on-browser': (url: string) => void;
'video-call-window/open-window': (url: string) => void;
'video-call-window/open-url': (url: string) => void;
'video-call-window/web-contents-id': (webContentsId: number) => void;
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { setupNotifications } from './notifications/main';
import { startOutlookCalendarUrlHandler } from './outlookCalendar/ipc';
import { setupScreenSharing } from './screenSharing/main';
import { setupServers } from './servers/main';
import { checkSupportedVersionServers } from './servers/supportedVersions/main';
import { setupSpellChecking } from './spellChecking/main';
import { createMainReduxStore } from './store';
import { handleCertificatesManager } from './ui/components/CertificatesManager/main';
Expand Down Expand Up @@ -97,6 +98,7 @@ const start = async (): Promise<void> => {
handleJitsiDesktopCapturerGetSources();
handleDesktopCapturerGetSources();
startOutlookCalendarUrlHandler();
checkSupportedVersionServers();

await processDeepLinksInArgs();
};
Expand Down
11 changes: 11 additions & 0 deletions src/servers/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { OutlookCredentials } from '../outlookCalendar/type';
import type {
MessageTranslated,
SupportedVersions,
} from './supportedVersions/types';

export type Server = {
url: string;
Expand All @@ -18,6 +22,13 @@ export type Server = {
gitCommitHash?: string;
allowedRedirects?: string[];
outlookCredentials?: OutlookCredentials;
version?: string;
workspaceUID?: string;
isSupportedVersion?: boolean;
supportedVersionsSource?: 'server' | 'cloud' | 'builtin';
supportedVersions?: SupportedVersions;
expirationMessage?: MessageTranslated;
expirationMessageLastTimeShown?: Date;
};

export const enum ServerUrlResolutionStatus {
Expand Down
6 changes: 6 additions & 0 deletions src/servers/preload/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import {
import { setTitle } from './title';
import { setUrlResolver } from './urls';
import { setUserLoggedIn } from './userLoggedIn';
import { setVersion } from './version';
import { setWorkspaceUID } from './workspaceUID';

type ServerInfo = {
version: string;
Expand Down Expand Up @@ -72,6 +74,8 @@ export type RocketChatDesktopAPI = {
hasOutlookCredentials: () => Promise<boolean>;
clearOutlookCredentials: () => void;
setUserToken: (token: string, userId: string) => void;
setWorkspaceUID: (workspaceUID: string) => void;
setVersion: (version: string) => void;
};

export const RocketChatDesktop: RocketChatDesktopAPI = {
Expand Down Expand Up @@ -104,5 +108,7 @@ export const RocketChatDesktop: RocketChatDesktopAPI = {
hasOutlookCredentials,
clearOutlookCredentials,
setUserToken,
setWorkspaceUID,
setVersion,
setSidebarCustomTheme,
};
14 changes: 14 additions & 0 deletions src/servers/preload/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { dispatch } from '../../store';
import { WEBVIEW_SERVER_VERSION_UPDATED } from '../../ui/actions';
import type { Server } from '../common';
import { getServerUrl } from './urls';

export const setVersion = (version: Server['version']): void => {
dispatch({
type: WEBVIEW_SERVER_VERSION_UPDATED,
payload: {
url: getServerUrl(),
version,
},
});
};
14 changes: 14 additions & 0 deletions src/servers/preload/workspaceUID.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { dispatch } from '../../store';
import { WEBVIEW_SERVER_WORKSPACE_UID_UPDATED } from '../../ui/actions';
import type { Server } from '../common';
import { getServerUrl } from './urls';

export const setWorkspaceUID = (workspaceUID: Server['workspaceUID']): void => {
dispatch({
type: WEBVIEW_SERVER_WORKSPACE_UID_UPDATED,
payload: {
url: getServerUrl(),
workspaceUID,
},
});
};
51 changes: 50 additions & 1 deletion src/servers/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ import {
WEBVIEW_ATTACHED,
WEBVIEW_GIT_COMMIT_HASH_CHANGED,
WEBVIEW_ALLOWED_REDIRECTS_CHANGED,
WEBVIEW_SERVER_SUPPORTED_VERSIONS_UPDATED,
WEBVIEW_SERVER_WORKSPACE_UID_UPDATED,
WEBVIEW_SERVER_IS_SUPPORTED_VERSION,
WEBVIEW_SERVER_VERSION_UPDATED,
SUPPORTED_VERSION_EXPIRATION_MESSAGE_UPDATED,
SUPPORTED_VERSION_DIALOG_DISMISS,
WEBVIEW_SIDEBAR_CUSTOM_THEME_CHANGED,
WEBVIEW_SERVER_SUPPORTED_VERSIONS_SOURCE_UPDATED,
} from '../ui/actions';
import { SERVERS_LOADED } from './actions';
import type { Server } from './common';
Expand Down Expand Up @@ -53,7 +60,14 @@ type ServersActionTypes =
| ActionOf<typeof WEBVIEW_DID_FAIL_LOAD>
| ActionOf<typeof WEBVIEW_READY>
| ActionOf<typeof WEBVIEW_ATTACHED>
| ActionOf<typeof OUTLOOK_CALENDAR_SAVE_CREDENTIALS>;
| ActionOf<typeof OUTLOOK_CALENDAR_SAVE_CREDENTIALS>
| ActionOf<typeof WEBVIEW_SERVER_SUPPORTED_VERSIONS_UPDATED>
| ActionOf<typeof WEBVIEW_SERVER_WORKSPACE_UID_UPDATED>
| ActionOf<typeof WEBVIEW_SERVER_IS_SUPPORTED_VERSION>
| ActionOf<typeof WEBVIEW_SERVER_VERSION_UPDATED>
| ActionOf<typeof SUPPORTED_VERSION_EXPIRATION_MESSAGE_UPDATED>
| ActionOf<typeof SUPPORTED_VERSION_DIALOG_DISMISS>
| ActionOf<typeof WEBVIEW_SERVER_SUPPORTED_VERSIONS_SOURCE_UPDATED>;

const upsert = (state: Server[], server: Server): Server[] => {
const index = state.findIndex(({ url }) => url === server.url);
Expand Down Expand Up @@ -107,6 +121,41 @@ export const servers: Reducer<Server[], ServersActionTypes> = (
return upsert(state, { url, title });
}

case WEBVIEW_SERVER_SUPPORTED_VERSIONS_UPDATED: {
const { url, supportedVersions } = action.payload;
return upsert(state, { url, supportedVersions });
}

case SUPPORTED_VERSION_EXPIRATION_MESSAGE_UPDATED: {
const { url, expirationMessage } = action.payload;
return upsert(state, { url, expirationMessage });
}

case WEBVIEW_SERVER_SUPPORTED_VERSIONS_SOURCE_UPDATED: {
const { url, supportedVersionsSource } = action.payload;
return upsert(state, { url, supportedVersionsSource });
}

case SUPPORTED_VERSION_DIALOG_DISMISS: {
const { url } = action.payload;
return upsert(state, { url, expirationMessageLastTimeShown: new Date() });
}

case WEBVIEW_SERVER_WORKSPACE_UID_UPDATED: {
const { url, workspaceUID } = action.payload;
return upsert(state, { url, workspaceUID });
}

case WEBVIEW_SERVER_IS_SUPPORTED_VERSION: {
const { url, isSupportedVersion } = action.payload;
return upsert(state, { url, isSupportedVersion });
}

case WEBVIEW_SERVER_VERSION_UPDATED: {
const { url, version } = action.payload;
return upsert(state, { url, version });
}

case WEBVIEW_UNREAD_CHANGED: {
const { url, badge } = action.payload;
return upsert(state, { url, badge });
Expand Down
42 changes: 42 additions & 0 deletions src/servers/supportedVersions/downloadFromCloud.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import fs from 'fs';

import type { AxiosResponse } from 'axios';
import axios from 'axios';

const apiUrl =
'https://releases.rocket.chat/v2/server/supportedVersions?source=desktop';
const outputFilePath = './app/supportedVersions.jwt';

interface SupportedVersionsResponse {
signed?: string;
}

export async function downloadAndSaveSupportedVersionsFromCloud(): Promise<void> {
console.log('Getting Supported Versions from Cloud...');
try {
const response: AxiosResponse<SupportedVersionsResponse> = await axios.get(
apiUrl
);

if (response.status === 200) {
const jsonData: SupportedVersionsResponse = response.data;

if (jsonData && jsonData.signed) {
const signedContent: string = jsonData.signed;

fs.writeFileSync(outputFilePath, signedContent);
console.log('Signed content saved successfully.');
} else {
console.error(
'JSON response does not contain the expected "signed" field.'
);
}
} else {
console.error('Failed to retrieve data from Cloud.');
}
} catch (error: any) {
console.error('Error getting the Supported Versions from Cloud:', error);
}
}

downloadAndSaveSupportedVersionsFromCloud();
Loading
Loading