Skip to content

Commit c2e9949

Browse files
authored
fix: Prevent video calls from being started in archived rooms (RocketChat#37109)
1 parent affd1ac commit c2e9949

4 files changed

Lines changed: 60 additions & 14 deletions

File tree

.changeset/sixty-ladybugs-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket.chat/meteor': patch
3+
---
4+
5+
Fixes an issue where the start call button is available in archived rooms

apps/meteor/client/hooks/roomActions/useVideoCallRoomAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const useVideoCallRoomAction = () => {
5050

5151
const visible = groups.length > 0;
5252
const allowed = visible && permittedToCallManagement && (!user?.username || !room.muted?.includes(user.username)) && !ownUser;
53-
const disabled = federated || (!!room.ro && !permittedToPostReadonly);
53+
const disabled = federated || (!!room.ro && !permittedToPostReadonly) || room.archived;
5454
const tooltip = disabled ? t('core.Video_Call_unavailable_for_this_type_of_room') : '';
5555

5656
const handleOpenVideoConf = useEffectEvent(async () => {

apps/meteor/tests/e2e/utils/create-target-channel.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,19 @@ export async function createChannelWithTeam(api: BaseTest['api']): Promise<Recor
100100

101101
return { channelName, teamName };
102102
}
103+
104+
export async function createArchivedChannel(api: BaseTest['api']): Promise<string> {
105+
const { channel } = await createTargetChannelAndReturnFullRoom(api);
106+
107+
try {
108+
await api.post('/channels.archive', { roomId: channel._id });
109+
} catch (error) {
110+
throw new Error(`Error archiving the channel: ${error}`);
111+
}
112+
113+
if (!channel.name) {
114+
throw new Error('Invalid channel was created');
115+
}
116+
117+
return channel.name;
118+
}

apps/meteor/tests/e2e/video-conference.spec.ts

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import { IS_EE } from './config/constants';
22
import { Users } from './fixtures/userStates';
33
import { HomeChannel } from './page-objects';
4-
import { createTargetChannel, setUserPreferences, createTargetTeam, createDirectMessage } from './utils';
4+
import {
5+
createArchivedChannel,
6+
createTargetChannel,
7+
setUserPreferences,
8+
createTargetTeam,
9+
createDirectMessage,
10+
deleteChannel,
11+
deleteTeam,
12+
} from './utils';
513
import { expect, test } from './utils/test';
614

715
test.use({ storageState: Users.user1.state });
@@ -11,15 +19,26 @@ test.describe('video conference', () => {
1119
let poHomeChannel: HomeChannel;
1220
let targetChannel: string;
1321
let targetReadOnlyChannel: string;
22+
let targetArchivedChannel: string;
1423
let targetTeam: string;
1524

1625
test.beforeAll(async ({ api }) => {
1726
targetChannel = await createTargetChannel(api);
1827
targetReadOnlyChannel = await createTargetChannel(api, { readOnly: true });
28+
targetArchivedChannel = await createArchivedChannel(api);
1929
targetTeam = await createTargetTeam(api);
2030
await createDirectMessage(api);
2131
});
2232

33+
test.afterAll(async ({ api }) => {
34+
await Promise.all([
35+
deleteChannel(api, targetChannel),
36+
deleteChannel(api, targetArchivedChannel),
37+
deleteChannel(api, targetReadOnlyChannel),
38+
deleteTeam(api, targetTeam),
39+
]);
40+
});
41+
2342
test.beforeEach(async ({ page }) => {
2443
poHomeChannel = new HomeChannel(page);
2544

@@ -47,7 +66,7 @@ test.describe('video conference', () => {
4766
await expect(poHomeChannel.content.videoConfMessageBlock.last()).toBeVisible();
4867
});
4968

50-
test.describe('test video conference message block', async () => {
69+
test.describe('video conference message block', async () => {
5170
test.use({ storageState: Users.admin.state });
5271

5372
test.beforeAll(async ({ api }) => {
@@ -58,22 +77,22 @@ test.describe('video conference', () => {
5877
await setUserPreferences(api, { displayAvatars: true });
5978
});
6079

61-
test('should not render avatars in video conference message block', async () => {
80+
test('should NOT render avatars in video conference message block', async () => {
6281
await poHomeChannel.sidenav.openChat(targetChannel);
6382

6483
await expect(poHomeChannel.content.videoConfMessageBlock.last().getByRole('figure')).toHaveCount(0);
6584
});
6685
});
6786

68-
test.describe('test received in a "target channel"', async () => {
87+
test.describe('verify if user2 received a invite call in targetChannel', async () => {
6988
test.use({ storageState: Users.user2.state });
70-
test('verify if user received a invite call from "targetChannel"', async () => {
89+
test('should display a message block in a targetChannel', async () => {
7190
await poHomeChannel.sidenav.openChat(targetChannel);
7291
await expect(poHomeChannel.content.videoConfMessageBlock.last()).toBeVisible();
7392
});
7493
});
7594

76-
test('expect create video conference in a direct', async () => {
95+
test('should create video conference in a direct room', async () => {
7796
await poHomeChannel.sidenav.openChat('user2');
7897

7998
await poHomeChannel.content.btnVideoCall.click();
@@ -89,23 +108,23 @@ test.describe('video conference', () => {
89108
});
90109
});
91110

92-
test('expect create video conference in a "targetTeam"', async () => {
111+
test('should create video conference in targetTeam', async () => {
93112
await poHomeChannel.sidenav.openChat(targetTeam);
94113

95114
await poHomeChannel.content.btnVideoCall.click();
96115
await poHomeChannel.content.btnStartVideoCall.click();
97116
await expect(poHomeChannel.content.videoConfMessageBlock.last()).toBeVisible();
98117
});
99118

100-
test.describe('verify if received from a "targetTeam"', async () => {
119+
test.describe('verify if user2 received from a targetTeam', async () => {
101120
test.use({ storageState: Users.user2.state });
102-
test('verify if user received from a "targetTeam"', async () => {
121+
test('should display a message block in a targetTeam', async () => {
103122
await poHomeChannel.sidenav.openChat(targetTeam);
104123
await expect(poHomeChannel.content.videoConfMessageBlock.last()).toBeVisible();
105124
});
106125
});
107126

108-
test('expect create video conference in a direct multiple', async () => {
127+
test('should create video conference in a direct multiple', async () => {
109128
await poHomeChannel.sidenav.openChat('rocketchat.internal.admin.test, user2');
110129

111130
await poHomeChannel.content.btnVideoCall.click();
@@ -115,15 +134,21 @@ test.describe('video conference', () => {
115134

116135
test.describe('received in a direct multiple', async () => {
117136
test.use({ storageState: Users.user2.state });
118-
test('verify if user received from a multiple', async () => {
137+
test('should display a message block in a direct multiple', async () => {
119138
await poHomeChannel.sidenav.openChat('rocketchat.internal.admin.test, user1');
120139
await expect(poHomeChannel.content.videoConfMessageBlock.last()).toBeVisible();
121140
});
122141
});
123142

124-
test('expect create video conference not available in a "targetReadOnlyChannel"', async () => {
143+
test('should NOT create video conference in a targetReadOnlyChannel', async () => {
125144
await poHomeChannel.sidenav.openChat(targetReadOnlyChannel);
126145

127-
await expect(poHomeChannel.content.btnVideoCall).hasAttribute('disabled');
146+
await expect(poHomeChannel.content.btnVideoCall).toBeDisabled();
147+
});
148+
149+
test('should NOT be able to create video conference in targetArchivedChannel', async () => {
150+
await poHomeChannel.sidenav.openChat(targetArchivedChannel);
151+
152+
await expect(poHomeChannel.content.btnVideoCall).toBeDisabled();
128153
});
129154
});

0 commit comments

Comments
 (0)