fix: compute correct LiveKit room name hash for Element Call

Element Call uses SHA256(room_id + "|m.call#ROOM") encoded as unpadded
base64 for LiveKit room names (via lk-jwt-service). The bot was using
the raw Matrix room ID, causing agent and user to join different rooms.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-02-20 07:16:35 +00:00
parent 39552d5e90
commit 578b6bb56f

13
bot.py
View File

@@ -2,6 +2,7 @@ import os
import json import json
import asyncio import asyncio
import base64 import base64
import hashlib
import io import io
import logging import logging
import re import re
@@ -389,13 +390,11 @@ class Bot:
"livekit_alias": room_id, "livekit_alias": room_id,
}]) }])
# Extract LiveKit room name from foci and dispatch agent # Compute LiveKit room name using same hash as lk-jwt-service
lk_room_name = room_id # fallback # SHA256(room_id + "|" + "m.call#ROOM") encoded as unpadded base64
for f in foci: lk_room_hash = hashlib.sha256((room_id + "|m.call#ROOM").encode()).digest()
if f.get("type") == "livekit" and f.get("livekit_alias"): lk_room_name = base64.b64encode(lk_room_hash).decode().rstrip("=")
lk_room_name = f["livekit_alias"] logger.info("LiveKit room name: %s (hashed from %s)", lk_room_name, room_id)
break
logger.info("LiveKit room name: %s (from foci_preferred)", lk_room_name)
if room_id not in self.dispatched_rooms: if room_id not in self.dispatched_rooms:
try: try: