mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
Replace Literal with VideoPlatform StrEnum for platform field
- Create VideoPlatform StrEnum with WHEREBY and JITSI values - Update rooms.py and meetings.py to use VideoPlatform enum - Update views/rooms.py and video_platforms/factory.py to use enum values - Generate new migration with proper server_default='whereby' - Apply migration successfully with backward compatibility - Fix linting and formatting issues Addresses PR feedback point 1: use StrEnum instead of Literal[]
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
"""Add platform field to rooms and meetings
|
"""Add VideoPlatform enum for rooms and meetings
|
||||||
|
|
||||||
Revision ID: 35e035defa85
|
Revision ID: 6e6ea8e607c5
|
||||||
Revises: 61882a919591
|
Revises: 61882a919591
|
||||||
Create Date: 2025-09-02 16:08:55.205173
|
Create Date: 2025-09-02 17:33:21.022214
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ import sqlalchemy as sa
|
|||||||
from alembic import op
|
from alembic import op
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision: str = "35e035defa85"
|
revision: str = "6e6ea8e607c5"
|
||||||
down_revision: Union[str, None] = "61882a919591"
|
down_revision: Union[str, None] = "61882a919591"
|
||||||
branch_labels: Union[str, Sequence[str], None] = None
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
depends_on: Union[str, Sequence[str], None] = None
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
@@ -6,7 +6,7 @@ from fastapi import HTTPException
|
|||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from reflector.db import get_database, metadata
|
from reflector.db import get_database, metadata
|
||||||
from reflector.db.rooms import Room
|
from reflector.db.rooms import Room, VideoPlatform
|
||||||
from reflector.utils import generate_uuid4
|
from reflector.utils import generate_uuid4
|
||||||
|
|
||||||
meetings = sa.Table(
|
meetings = sa.Table(
|
||||||
@@ -91,7 +91,7 @@ class Meeting(BaseModel):
|
|||||||
"none", "prompt", "automatic", "automatic-2nd-participant"
|
"none", "prompt", "automatic", "automatic-2nd-participant"
|
||||||
] = "automatic-2nd-participant"
|
] = "automatic-2nd-participant"
|
||||||
num_clients: int = 0
|
num_clients: int = 0
|
||||||
platform: Literal["whereby", "jitsi"] = "whereby"
|
platform: VideoPlatform = VideoPlatform.WHEREBY
|
||||||
|
|
||||||
|
|
||||||
class MeetingController:
|
class MeetingController:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import secrets
|
import secrets
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
from enum import StrEnum
|
||||||
from sqlite3 import IntegrityError
|
from sqlite3 import IntegrityError
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
|
|
||||||
@@ -11,6 +12,12 @@ from sqlalchemy.sql import false, or_
|
|||||||
from reflector.db import get_database, metadata
|
from reflector.db import get_database, metadata
|
||||||
from reflector.utils import generate_uuid4
|
from reflector.utils import generate_uuid4
|
||||||
|
|
||||||
|
|
||||||
|
class VideoPlatform(StrEnum):
|
||||||
|
WHEREBY = "whereby"
|
||||||
|
JITSI = "jitsi"
|
||||||
|
|
||||||
|
|
||||||
rooms = sqlalchemy.Table(
|
rooms = sqlalchemy.Table(
|
||||||
"room",
|
"room",
|
||||||
metadata,
|
metadata,
|
||||||
@@ -67,7 +74,7 @@ class Room(BaseModel):
|
|||||||
is_shared: bool = False
|
is_shared: bool = False
|
||||||
webhook_url: str | None = None
|
webhook_url: str | None = None
|
||||||
webhook_secret: str | None = None
|
webhook_secret: str | None = None
|
||||||
platform: Literal["whereby", "jitsi"] = "whereby"
|
platform: VideoPlatform = VideoPlatform.WHEREBY
|
||||||
|
|
||||||
|
|
||||||
class RoomController:
|
class RoomController:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from reflector.db.rooms import VideoPlatform
|
||||||
from reflector.settings import settings
|
from reflector.settings import settings
|
||||||
|
|
||||||
from .base import VideoPlatformClient, VideoPlatformConfig
|
from .base import VideoPlatformClient, VideoPlatformConfig
|
||||||
@@ -10,7 +11,7 @@ from .registry import get_platform_client
|
|||||||
|
|
||||||
def get_platform_config(platform: str) -> VideoPlatformConfig:
|
def get_platform_config(platform: str) -> VideoPlatformConfig:
|
||||||
"""Get configuration for a specific platform."""
|
"""Get configuration for a specific platform."""
|
||||||
if platform == "whereby":
|
if platform == VideoPlatform.WHEREBY:
|
||||||
return VideoPlatformConfig(
|
return VideoPlatformConfig(
|
||||||
api_key=settings.WHEREBY_API_KEY or "",
|
api_key=settings.WHEREBY_API_KEY or "",
|
||||||
webhook_secret=settings.WHEREBY_WEBHOOK_SECRET or "",
|
webhook_secret=settings.WHEREBY_WEBHOOK_SECRET or "",
|
||||||
@@ -18,7 +19,7 @@ def get_platform_config(platform: str) -> VideoPlatformConfig:
|
|||||||
aws_access_key_id=settings.AWS_WHEREBY_ACCESS_KEY_ID,
|
aws_access_key_id=settings.AWS_WHEREBY_ACCESS_KEY_ID,
|
||||||
aws_access_key_secret=settings.AWS_WHEREBY_ACCESS_KEY_SECRET,
|
aws_access_key_secret=settings.AWS_WHEREBY_ACCESS_KEY_SECRET,
|
||||||
)
|
)
|
||||||
elif platform == "jitsi":
|
elif platform == VideoPlatform.JITSI:
|
||||||
return VideoPlatformConfig(
|
return VideoPlatformConfig(
|
||||||
api_key="", # Jitsi uses JWT, no API key
|
api_key="", # Jitsi uses JWT, no API key
|
||||||
webhook_secret=settings.JITSI_WEBHOOK_SECRET or "",
|
webhook_secret=settings.JITSI_WEBHOOK_SECRET or "",
|
||||||
@@ -37,4 +38,4 @@ def create_platform_client(platform: str) -> VideoPlatformClient:
|
|||||||
def get_platform_for_room(room_id: Optional[str] = None) -> str:
|
def get_platform_for_room(room_id: Optional[str] = None) -> str:
|
||||||
"""Determine which platform to use for a room based on feature flags."""
|
"""Determine which platform to use for a room based on feature flags."""
|
||||||
# For now, default to whereby since we don't have feature flags yet
|
# For now, default to whereby since we don't have feature flags yet
|
||||||
return "whereby"
|
return VideoPlatform.WHEREBY
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from pydantic import BaseModel
|
|||||||
import reflector.auth as auth
|
import reflector.auth as auth
|
||||||
from reflector.db import get_database
|
from reflector.db import get_database
|
||||||
from reflector.db.meetings import meetings_controller
|
from reflector.db.meetings import meetings_controller
|
||||||
from reflector.db.rooms import rooms_controller
|
from reflector.db.rooms import VideoPlatform, rooms_controller
|
||||||
from reflector.settings import settings
|
from reflector.settings import settings
|
||||||
from reflector.worker.webhook import test_webhook
|
from reflector.worker.webhook import test_webhook
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ class Room(BaseModel):
|
|||||||
recording_type: str
|
recording_type: str
|
||||||
recording_trigger: str
|
recording_trigger: str
|
||||||
is_shared: bool
|
is_shared: bool
|
||||||
platform: str = "whereby"
|
platform: VideoPlatform = VideoPlatform.WHEREBY
|
||||||
|
|
||||||
|
|
||||||
class RoomDetails(Room):
|
class RoomDetails(Room):
|
||||||
@@ -86,7 +86,7 @@ class CreateRoom(BaseModel):
|
|||||||
is_shared: bool
|
is_shared: bool
|
||||||
webhook_url: str
|
webhook_url: str
|
||||||
webhook_secret: str
|
webhook_secret: str
|
||||||
platform: str = "whereby"
|
platform: VideoPlatform = VideoPlatform.WHEREBY
|
||||||
|
|
||||||
|
|
||||||
class UpdateRoom(BaseModel):
|
class UpdateRoom(BaseModel):
|
||||||
@@ -101,7 +101,7 @@ class UpdateRoom(BaseModel):
|
|||||||
is_shared: bool
|
is_shared: bool
|
||||||
webhook_url: str
|
webhook_url: str
|
||||||
webhook_secret: str
|
webhook_secret: str
|
||||||
platform: str = "whereby"
|
platform: VideoPlatform = VideoPlatform.WHEREBY
|
||||||
|
|
||||||
|
|
||||||
class DeletionStatus(BaseModel):
|
class DeletionStatus(BaseModel):
|
||||||
|
|||||||
Reference in New Issue
Block a user