Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

♻️(backend) merge room name regex and centralize patterns in enums

lebaudantoine0ba445895ce9
diff --git a/src/backend/core/api/viewsets.py b/src/backend/core/api/viewsets.py
index 90d177b2..36705659 100644
--- a/src/backend/core/api/viewsets.py
+++ b/src/backend/core/api/viewsets.py
@@ -1,7 +1,6 @@
"""API endpoints"""
# pylint: disable=too-many-lines
-import re
import uuid
from logging import getLogger
from urllib.parse import unquote, urlparse
@@ -34,6 +33,7 @@ from rest_framework import (
from core import enums, models, utils
from core.api.filters import ListFileFilter
+from core.enums import MEDIA_STORAGE_URL_PATTERN
from core.recording.enums import FileExtension
from core.recording.event.authentication import StorageEventAuthentication
from core.recording.event.exceptions import (
@@ -78,16 +78,6 @@ from .feature_flag import FeatureFlag
logger = getLogger(__name__)
-FILE_FOLDER = settings.FILE_UPLOAD_PATH
-UUID_REGEX = (
- r"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}"
-)
-FILE_EXT_REGEX = r"[\d\w]+"
-MEDIA_STORAGE_URL_PATTERN = re.compile(
- f"{settings.MEDIA_URL:s}"
- rf"(?P<key>{FILE_FOLDER:s}/(?P<pk>{UUID_REGEX:s})\.{FILE_EXT_REGEX:s})$"
-)
-
class NestedGenericViewSet(viewsets.GenericViewSet):
"""
diff --git a/src/backend/core/enums.py b/src/backend/core/enums.py
index 2e3fa593..9f7e237a 100644
--- a/src/backend/core/enums.py
+++ b/src/backend/core/enums.py
@@ -17,6 +17,12 @@ RECORDING_STORAGE_URL_PATTERN = re.compile(
f"/media/{settings.RECORDING_OUTPUT_FOLDER}/(?P<recording_id>{UUID_REGEX:s}).(?P<extension>{FILE_EXT_REGEX:s})"
)
+MEDIA_STORAGE_URL_PATTERN = re.compile(
+ f"{settings.MEDIA_URL:s}"
+ rf"(?P<key>{settings.FILE_UPLOAD_PATH:s}/(?P<pk>{UUID_REGEX:s})\.{FILE_EXT_REGEX:s})$"
+)
+
+
# Django sets `LANGUAGES` by default with all supported languages. We can use it for
# the choice of languages which should not be limited to the few languages active in
# the app.