Skip to content

Commit

Permalink
fix: call-management permission not doing anything (RocketChat#29524)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc authored Jul 3, 2023
1 parent 6493478 commit 8ac0758
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/call-management-permission.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

fix: Permission to start conference calls was not being considered
4 changes: 4 additions & 0 deletions apps/meteor/app/api/server/v1/videoConference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ API.v1.addRoute(
return API.v1.failure('invalid-params');
}

if (!(await hasPermissionAsync(userId, 'call-management', roomId))) {
return API.v1.unauthorized();
}

try {
const providerName = videoConfProviders.getActiveProvider();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const permissions = [
{ _id: 'preview-c-room', roles: ['admin', 'user', 'anonymous'] },
{ _id: 'view-outside-room', roles: ['admin', 'owner', 'moderator', 'user'] },
{ _id: 'view-broadcast-member-list', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'call-management', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'call-management', roles: ['admin', 'owner', 'moderator', 'user'] },
{ _id: 'create-invite-links', roles: ['admin', 'owner', 'moderator'] },
{
_id: 'view-l-room',
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/app/videobridge/client/tabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ addAction('start-call', ({ room }) => {
const isRinging = useVideoConfIsRinging();
const federated = isRoomFederated(room);
const canPostReadOnly = usePermission('post-readonly', room._id);
const canStartCall = usePermission('call-management', room._id);

const ownUser = room.uids && room.uids.length === 1;

Expand All @@ -57,7 +58,7 @@ addAction('start-call', ({ room }) => {
const live = room?.streamingOptions && room.streamingOptions.type === 'call';
const enabled = enabledDMs || enabledChannel || enabledTeams || enabledGroups || enabledLiveChat;

const enableOption = enabled && (!user?.username || !room.muted?.includes(user.username));
const enableOption = enabled && canStartCall && (!user?.username || !room.muted?.includes(user.username));

const groups = useStableArray(
[
Expand Down

0 comments on commit 8ac0758

Please sign in to comment.