add room/participant name limit (#2704)

* add room/participant name limit

* defaults

* simplify

* omitempty

* handle 0 config

* fix race

* unlock

* tidy
This commit is contained in:
Paul Wells
2024-05-06 17:25:18 -07:00
committed by GitHub
parent 65f06da1ca
commit 9a5db132eb
7 changed files with 63 additions and 52 deletions
+5
View File
@@ -16,6 +16,7 @@ package service
import (
"context"
"fmt"
"strconv"
"github.com/avast/retry-go/v4"
@@ -83,6 +84,10 @@ func (s *RoomService) CreateRoom(ctx context.Context, req *livekit.CreateRoomReq
return nil, ErrEgressNotConnected
}
if limit := s.roomConf.MaxRoomNameLength; limit > 0 && len(req.Name) > limit {
return nil, fmt.Errorf("%w: max length %d", ErrRoomNameExceedsLimits, limit)
}
rm, created, err := s.roomAllocator.CreateRoom(ctx, req)
if err != nil {
err = errors.Wrap(err, "could not create room")