From aeb5c3790c345b4a5785a9560e77138cfce1d706 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Thu, 28 Aug 2025 14:26:51 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(frontend)=20refactor=20permi?= =?UTF-8?q?ssion=20updates=20to=20preserve=20admin=20privileges?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhance participant permission update logic to only affect users without room privileges, ensuring admins can maintain their microphone and camera access during bulk permission changes. Prevents accidental disruption of admin functionality when applying permission restrictions to regular participants, maintaining proper role-based access control hierarchy. --- .../rooms/livekit/hooks/usePublishSourcesManager.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/features/rooms/livekit/hooks/usePublishSourcesManager.ts b/src/frontend/src/features/rooms/livekit/hooks/usePublishSourcesManager.ts index e14f70d0..71a1bfd1 100644 --- a/src/frontend/src/features/rooms/livekit/hooks/usePublishSourcesManager.ts +++ b/src/frontend/src/features/rooms/livekit/hooks/usePublishSourcesManager.ts @@ -8,6 +8,7 @@ import { useRemoteParticipants } from '@livekit/components-react' import { useUpdateParticipantsPermissions } from '@/features/rooms/api/updateParticipantsPermissions' import { useRoomData } from '@/features/rooms/livekit/hooks/useRoomData' import { isSubsetOf } from '@/features/rooms/utils/isSubsetOf' +import { getParticipantIsRoomAdmin } from '@/features/rooms/utils/getParticipantIsRoomAdmin' import Source = Track.Source export const updatePublishSources = ( @@ -42,7 +43,9 @@ export const usePublishSourcesManager = () => { const { updateParticipantsPermissions } = useUpdateParticipantsPermissions() const remoteParticipants = useRemoteParticipants() - // todo - filter, update only contributors and not admin + const unprivilegedRemoteParticipants = remoteParticipants.filter( + (participant) => !getParticipantIsRoomAdmin(participant) + ) const currentSources = useMemo(() => { if ( @@ -79,7 +82,10 @@ export const usePublishSourcesManager = () => { queryClient.setQueryData([keys.room, roomId], room) - await updateParticipantsPermissions(remoteParticipants, newSources) + await updateParticipantsPermissions( + unprivilegedRemoteParticipants, + newSources + ) return { configuration: newConfiguration } } catch (error) { @@ -92,7 +98,7 @@ export const usePublishSourcesManager = () => { currentSources, roomId, patchRoom, - remoteParticipants, + unprivilegedRemoteParticipants, updateParticipantsPermissions, ] )