Skip to content

Commit

Permalink
Release 6.9.2
Browse files Browse the repository at this point in the history
Release 6.9.2
  • Loading branch information
ggazzo authored Jun 18, 2024
2 parents ce72824 + 904f970 commit 2f004f1
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/bump-patch-1718743154258.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Bump @rocket.chat/meteor version.
5 changes: 5 additions & 0 deletions .changeset/dry-shoes-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes the supported versions problem, where in most cases the data chosen was the oldest
5 changes: 5 additions & 0 deletions .changeset/nervous-wolves-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes the issue not allowing users without edit-room-retention-policy permission try to edit the room with the retention policy enabled
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { SignedSupportedVersions } from '@rocket.chat/server-cloud-communic

export const supportedVersionsChooseLatest = async (...tokens: (SignedSupportedVersions | undefined)[]) => {
const [token] = (tokens.filter((r) => r?.timestamp != null) as SignedSupportedVersions[]).sort((a, b) => {
return new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime();
return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime();
});

return token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const cacheValueInSettings = <T extends SettingValue>(
reset: () => Promise<T>;
} => {
const reset = async () => {
SystemLogger.debug(`Resetting cached value ${key} in settings`);
const value = await fn();

await Settings.updateValueById(key, value);
Expand Down Expand Up @@ -134,6 +135,31 @@ const getSupportedVersionsToken = async () => {
(response.success && response.result) || undefined,
);

SystemLogger.debug({
msg: 'Supported versions',
supportedVersionsFromBuild: supportedVersionsFromBuild.timestamp,
versionsFromLicense: versionsFromLicense?.supportedVersions?.timestamp,
response: response.success && response.result?.timestamp,
});

switch (supportedVersions) {
case supportedVersionsFromBuild:
SystemLogger.info({
msg: 'Using supported versions from build',
});
break;
case versionsFromLicense?.supportedVersions:
SystemLogger.info({
msg: 'Using supported versions from license',
});
break;
case response.success && response.result:
SystemLogger.info({
msg: 'Using supported versions from cloud',
});
break;
}

await buildVersionUpdateMessage(supportedVersions?.versions);

return supportedVersions?.signed;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import type { IRoomWithRetentionPolicy } from '@rocket.chat/core-typings';
import { usePermission } from '@rocket.chat/ui-contexts';
import { useMemo } from 'react';

import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator';
import { useRetentionPolicy } from '../../../hooks/useRetentionPolicy';

export const useEditRoomInitialValues = (room: IRoomWithRetentionPolicy) => {
const retentionPolicy = useRetentionPolicy(room);
const canEditRoomRetentionPolicy = usePermission('edit-room-retention-policy', room._id);

const { t, ro, archived, topic, description, announcement, joinCodeRequired, sysMes, encrypted, retention, reactWhenReadOnly } = room;

return useMemo(
Expand All @@ -24,13 +27,14 @@ export const useEditRoomInitialValues = (room: IRoomWithRetentionPolicy) => {
systemMessages: Array.isArray(sysMes) ? sysMes : [],
hideSysMes: Array.isArray(sysMes) ? !!sysMes?.length : !!sysMes,
encrypted,
...(retentionPolicy?.enabled && {
retentionEnabled: retention?.enabled ?? retentionPolicy.isActive,
retentionOverrideGlobal: !!retention?.overrideGlobal,
retentionMaxAge: retention?.maxAge ?? retentionPolicy.maxAge,
retentionExcludePinned: retention?.excludePinned ?? retentionPolicy.excludePinned,
retentionFilesOnly: retention?.filesOnly ?? retentionPolicy.filesOnly,
}),
...(canEditRoomRetentionPolicy &&
retentionPolicy?.enabled && {
retentionEnabled: retention?.enabled ?? retentionPolicy.isActive,
retentionOverrideGlobal: !!retention?.overrideGlobal,
retentionMaxAge: retention?.maxAge ?? retentionPolicy.maxAge,
retentionExcludePinned: retention?.excludePinned ?? retentionPolicy.excludePinned,
retentionFilesOnly: retention?.filesOnly ?? retentionPolicy.filesOnly,
}),
}),
[
announcement,
Expand All @@ -46,6 +50,7 @@ export const useEditRoomInitialValues = (room: IRoomWithRetentionPolicy) => {
topic,
encrypted,
reactWhenReadOnly,
canEditRoomRetentionPolicy,
],
);
};
1 change: 1 addition & 0 deletions apps/meteor/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const config: Config = {
'<rootDir>/app/livechat/server/business-hour/**/*.spec.ts?(x)',
'<rootDir>/app/livechat/server/api/**/*.spec.ts',
'<rootDir>/ee/app/authorization/server/validateUserRoles.spec.ts',
'<rootDir>/app/cloud/server/functions/supportedVersionsToken/**.spec.ts',
],
transformIgnorePatterns: ['!/node_modules/jose'],
errorOnDeprecated: true,
Expand Down
23 changes: 18 additions & 5 deletions apps/meteor/packages/rocketchat-version/plugin/compile-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class VersionCompiler {
function handleError(err) {
console.error(err);
// TODO remove this when we are ready to fail
// if (process.env.NODE_ENV !== 'development') {
// reject(err);
// return;
// }
if (process.env.NODE_ENV !== 'development') {
reject(err);
return;
}
resolve({});
}

Expand All @@ -34,11 +34,24 @@ class VersionCompiler {
response.on('data', function (chunk) {
data += chunk;
});
response.on('end', function () {
response.on('end', async function () {
const supportedVersions = JSON.parse(data);
if (!supportedVersions?.signed) {
return handleError(new Error(`Invalid supportedVersions result:\n URL: ${url} \n RESULT: ${data}`));
}

// check if timestamp is inside 1 hour within build
if (Math.abs(new Date().getTime() - new Date(supportedVersions.timestamp).getTime()) > 1000 * 60 * 60) {
return handleError(new Error(`Invalid supportedVersions timestamp:\n URL: ${url} \n RESULT: ${data}`));
}

for await (const version of supportedVersions.versions) {
// check if expiration is after the first rocket.chat release
if (new Date(version.expiration) < new Date('2019-04-01T00:00:00.000Z')) {
return handleError(new Error(`Invalid supportedVersions expiration:\n URL: ${url} \n RESULT: ${data}`));
}
}

resolve(supportedVersions);
});
response.on('error', function (err) {
Expand Down
33 changes: 24 additions & 9 deletions apps/meteor/tests/e2e/retention-policy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,31 @@ test.describe.serial('retention-policy', () => {
await expect(poHomeChannel.tabs.room.pruneAccordion).toBeVisible();
});

test('should not show prune section in edit channel for users without permission', async ({ browser }) => {
const { page } = await createAuxContext(browser, Users.user1);
const auxContext = { page, poHomeChannel: new HomeChannel(page) };
await auxContext.poHomeChannel.sidenav.openChat(targetChannel);
await auxContext.poHomeChannel.tabs.btnRoomInfo.click();
await auxContext.poHomeChannel.tabs.room.btnEdit.click();
test.describe('edit-room-retention-policy permission', async () => {
test('should not show prune section in edit channel for users without permission', async ({ browser }) => {
const { page } = await createAuxContext(browser, Users.user1);
const auxContext = { page, poHomeChannel: new HomeChannel(page) };
await auxContext.poHomeChannel.sidenav.openChat(targetChannel);
await auxContext.poHomeChannel.tabs.btnRoomInfo.click();
await auxContext.poHomeChannel.tabs.room.btnEdit.click();

await expect(poHomeChannel.tabs.room.pruneAccordion).not.toBeVisible();
await auxContext.page.close();
});

await expect(poHomeChannel.tabs.room.pruneAccordion).not.toBeVisible();
await auxContext.page.close();
})
test('users without permission should be able to edit the channel', async ({ browser }) => {
const { page } = await createAuxContext(browser, Users.user1);
const auxContext = { page, poHomeChannel: new HomeChannel(page) };
await auxContext.poHomeChannel.sidenav.openChat(targetChannel);
await auxContext.poHomeChannel.tabs.btnRoomInfo.click();
await auxContext.poHomeChannel.tabs.room.btnEdit.click();
await auxContext.poHomeChannel.tabs.room.checkboxReadOnly.check();
await auxContext.poHomeChannel.tabs.room.btnSave.click();

await expect(auxContext.poHomeChannel.getSystemMessageByText('set room to read only')).toBeVisible();
await auxContext.page.close();
});
});

test.describe('retention policy applies enabled by default', () => {
test.beforeAll(async ({ api }) => {
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8795,10 +8795,10 @@ __metadata:
"@rocket.chat/icons": "*"
"@rocket.chat/prettier-config": "*"
"@rocket.chat/styled": "*"
"@rocket.chat/ui-avatar": 3.0.0
"@rocket.chat/ui-contexts": 7.0.0
"@rocket.chat/ui-avatar": 3.0.1
"@rocket.chat/ui-contexts": 7.0.1
"@rocket.chat/ui-kit": 0.34.0
"@rocket.chat/ui-video-conf": 7.0.0
"@rocket.chat/ui-video-conf": 7.0.1
"@tanstack/react-query": "*"
react: "*"
react-dom: "*"
Expand Down Expand Up @@ -8887,8 +8887,8 @@ __metadata:
"@rocket.chat/fuselage-tokens": "*"
"@rocket.chat/message-parser": 0.31.29
"@rocket.chat/styled": "*"
"@rocket.chat/ui-client": 7.0.0
"@rocket.chat/ui-contexts": 7.0.0
"@rocket.chat/ui-client": 7.0.1
"@rocket.chat/ui-contexts": 7.0.1
katex: "*"
react: "*"
languageName: unknown
Expand Down Expand Up @@ -10106,7 +10106,7 @@ __metadata:
typescript: ~5.3.3
peerDependencies:
"@rocket.chat/fuselage": "*"
"@rocket.chat/ui-contexts": 7.0.0
"@rocket.chat/ui-contexts": 7.0.1
react: ~17.0.2
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -10159,7 +10159,7 @@ __metadata:
"@rocket.chat/fuselage": "*"
"@rocket.chat/fuselage-hooks": "*"
"@rocket.chat/icons": "*"
"@rocket.chat/ui-contexts": 7.0.0
"@rocket.chat/ui-contexts": 7.0.1
react: ~17.0.2
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -10335,8 +10335,8 @@ __metadata:
"@rocket.chat/fuselage-hooks": "*"
"@rocket.chat/icons": "*"
"@rocket.chat/styled": "*"
"@rocket.chat/ui-avatar": 3.0.0
"@rocket.chat/ui-contexts": 7.0.0
"@rocket.chat/ui-avatar": 3.0.1
"@rocket.chat/ui-contexts": 7.0.1
react: ^17.0.2
react-dom: ^17.0.2
languageName: unknown
Expand Down Expand Up @@ -10426,7 +10426,7 @@ __metadata:
peerDependencies:
"@rocket.chat/layout": "*"
"@rocket.chat/tools": 0.2.1
"@rocket.chat/ui-contexts": 7.0.0
"@rocket.chat/ui-contexts": 7.0.1
"@tanstack/react-query": "*"
react: "*"
react-hook-form: "*"
Expand Down

0 comments on commit 2f004f1

Please sign in to comment.