mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 15:35:41 +00:00
Allow specifying room configuration in token (#2853)
This commit is contained in:
@@ -172,6 +172,16 @@ func EnsureCreatePermission(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetRoomConfiguration(ctx context.Context) string {
|
||||
|
||||
claims := GetGrants(ctx)
|
||||
|
||||
if claims == nil || claims.Video == nil {
|
||||
return ""
|
||||
}
|
||||
return claims.Video.RoomConfiguration
|
||||
}
|
||||
|
||||
func EnsureListPermission(ctx context.Context) error {
|
||||
claims := GetGrants(ctx)
|
||||
if claims == nil || claims.Video == nil || !claims.Video.RoomList {
|
||||
|
||||
@@ -207,7 +207,7 @@ func (r *StandardRoomAllocator) applyNamedRoomConfiguration(req *livekit.CreateR
|
||||
|
||||
conf, ok := r.config.Room.RoomConfigurations[req.ConfigName]
|
||||
if !ok {
|
||||
return nil, psrpc.NewErrorf(psrpc.InvalidArgument, "unknown roomc confguration in create room request")
|
||||
return req, psrpc.NewErrorf(psrpc.InvalidArgument, "unknown room confguration in create room request")
|
||||
}
|
||||
|
||||
clone := proto.Clone(req).(*livekit.CreateRoomRequest)
|
||||
|
||||
@@ -515,7 +515,8 @@ func (s *RTCService) startConnection(
|
||||
var cr connectionResult
|
||||
var created bool
|
||||
var err error
|
||||
cr.Room, created, err = s.roomAllocator.CreateRoom(ctx, &livekit.CreateRoomRequest{Name: string(roomName)})
|
||||
|
||||
cr.Room, created, err = s.roomAllocator.CreateRoom(ctx, &livekit.CreateRoomRequest{Name: string(roomName), ConfigName: GetRoomConfiguration(ctx)})
|
||||
if err != nil {
|
||||
return cr, nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user