♻️(frontend) refactor permission updates to preserve admin privileges
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.
This commit is contained in:
committed by
aleb_the_flash
parent
3e69a2380f
commit
aeb5c3790c
@@ -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,
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user