From 0cda3b09ec89c5c63a4552f3eeaee22d97ee3285 Mon Sep 17 00:00:00 2001 From: talksik Date: Wed, 1 Apr 2026 08:55:17 -0700 Subject: [PATCH] set human name in livekit room context --- go/internal/handler/handler.go | 7 ++++++- go/internal/livekit/client.go | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/go/internal/handler/handler.go b/go/internal/handler/handler.go index c037a74..0de9519 100644 --- a/go/internal/handler/handler.go +++ b/go/internal/handler/handler.go @@ -1064,6 +1064,11 @@ func (h *Handler) GetLivekitToken(w http.ResponseWriter, r *http.Request) { http.Error(w, "unauthorized", http.StatusUnauthorized) return } + humanEmail, ok := middleware.EmailFromContext(r.Context()) + if !ok { + http.Error(w, "unauthorized", http.StatusUnauthorized) + return + } var req GetLivekitTokenRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { @@ -1076,7 +1081,7 @@ func (h *Handler) GetLivekitToken(w http.ResponseWriter, r *http.Request) { return } - token, err := h.livekitClient.GetJoinToken(req.RoomId, humanId) + token, err := h.livekitClient.GetJoinToken(req.RoomId, humanId, humanEmail) if err != nil { slog.Error("failed to generate livekit token", "error", err, "humanId", humanId, "roomId", req.RoomId) http.Error(w, "failed to generate token", http.StatusInternalServerError) diff --git a/go/internal/livekit/client.go b/go/internal/livekit/client.go index a2cea03..dc57846 100644 --- a/go/internal/livekit/client.go +++ b/go/internal/livekit/client.go @@ -8,7 +8,8 @@ import ( ) type Client interface { - GetJoinToken(roomId string, identity string) (string, error) + // Name will show up in the participant data + GetJoinToken(roomId string, humanId string, name string) (string, error) ServerUrl() string } @@ -30,14 +31,15 @@ func (c *clientImpl) ServerUrl() string { return c.hostUrl } -func (c *clientImpl) GetJoinToken(room, identity string) (string, error) { +func (c *clientImpl) GetJoinToken(room, humanId, name string) (string, error) { at := auth.NewAccessToken(c.apiKey, c.apiSecret) grant := &auth.VideoGrant{ RoomJoin: true, Room: room, } at.SetVideoGrant(grant). - SetIdentity(identity). + SetIdentity(humanId). + SetName(name). SetValidFor(time.Hour) return at.ToJWT()