Skip to content

Commit ff1502b

Browse files
committed
Infer from timestamps if the LiveKit room has actually been created and adapt logging.
1 parent c280b23 commit ff1502b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ func (h *Handler) handle(w http.ResponseWriter, r *http.Request) {
259259

260260
if isFullAccessUser {
261261
roomClient := lksdk.NewRoomServiceClient(h.lkUrl, h.key, h.secret)
262+
creationStart := time.Now().Unix()
262263
room, err := roomClient.CreateRoom(
263264
context.Background(), &livekit.CreateRoomRequest{
264265
Name: sfuAccessRequest.Room,
@@ -282,7 +283,13 @@ func (h *Handler) handle(w http.ResponseWriter, r *http.Request) {
282283
return
283284
}
284285

285-
log.Printf("Created LiveKit room sid: %s (alias: %s) for local Matrix user %s (LiveKit identity: %s)", room.Sid, sfuAccessRequest.Room, userInfo.Sub , lkIdentity)
286+
// Log the room creation time and the user info
287+
isNewRoom := room.GetCreationTime() >= creationStart && room.GetCreationTime() <= time.Now().Unix()
288+
log.Printf(
289+
"%s LiveKit room sid: %s (alias: %s) for full-access Matrix user %s (LiveKit identity: %s)",
290+
map[bool]string{true: "Created", false: "Using"}[isNewRoom],
291+
room.Sid, sfuAccessRequest.Room, userInfo.Sub , lkIdentity,
292+
)
286293
}
287294

288295
res := SFUResponse{URL: h.lkUrl, JWT: token}

0 commit comments

Comments
 (0)