mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-17 14:07:49 +00:00
✨(backend) add connection-test API
Currently users have no way to reliably test their connection before joining a room. To address this, we plan to build a connection-test page. The testing requires a dedicated LiveKit token, issued without going through the room API, which is tied to registered meetings, lobby rules, and longer-lived access tokens. Introduce a new viewset for all diagnostics-related features. The first route issues a token for diagnostics, even for anonymous users. Each request creates a new dedicated room so users never share the same LiveKit room during tests. Tokens are short-lived (default 10 minutes) to limit reuse, and the endpoint is throttled to prevent abuse. A Celery worker also schedules a callback that deletes the room after a certain delay, in every case.
This commit is contained in:
committed by
lebaudantoine
parent
6c69c3d6e3
commit
0805cbdb2d
@@ -0,0 +1,9 @@
|
||||
"""Celery tasks for the core app."""
|
||||
|
||||
from core.tasks.connection_test import delete_connection_test_room
|
||||
from core.tasks.file import process_file_deletion
|
||||
|
||||
__all__ = (
|
||||
"delete_connection_test_room",
|
||||
"process_file_deletion",
|
||||
)
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
"""Tasks related to connection test rooms."""
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from asgiref.sync import async_to_sync
|
||||
from livekit.api import ( # pylint: disable=no-name-in-module
|
||||
DeleteRoomRequest,
|
||||
TwirpError,
|
||||
)
|
||||
|
||||
from core.tasks._task import task
|
||||
from core.utils import create_livekit_client
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@task
|
||||
def delete_connection_test_room(room_name: str):
|
||||
"""Force-delete an ephemeral connection-test room.
|
||||
|
||||
Used as a hard cap so a participant cannot keep an auto-refreshed
|
||||
LiveKit session open indefinitely after requesting a test token.
|
||||
"""
|
||||
prefix = settings.CONNECTION_TEST_ROOM_PREFIX
|
||||
if not room_name.startswith(prefix):
|
||||
logger.error(
|
||||
"Refusing to delete room '%s': expected prefix '%s'.",
|
||||
room_name,
|
||||
prefix,
|
||||
)
|
||||
return
|
||||
|
||||
async_to_sync(_delete_room)(room_name)
|
||||
|
||||
|
||||
async def _delete_room(room_name: str):
|
||||
lkapi = create_livekit_client()
|
||||
try:
|
||||
await lkapi.room.delete_room(DeleteRoomRequest(room=room_name))
|
||||
logger.info("Deleted connection test room '%s'.", room_name)
|
||||
except TwirpError as exc:
|
||||
# Room may already be gone after empty/departure timeout.
|
||||
logger.info(
|
||||
"Could not delete connection test room '%s': %s",
|
||||
room_name,
|
||||
exc,
|
||||
)
|
||||
finally:
|
||||
await lkapi.aclose()
|
||||
Reference in New Issue
Block a user