mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
feat: clean up legacy code and remove excessive documentation
- Remove excessive inline comments from meeting creation flow - Remove verbose docstrings from simple property methods and basic functions - Clean up obvious comments like 'Generate JWT tokens', 'Build room URLs' - Remove unnecessary explanatory comments in platform clients - Keep only essential documentation for complex logic - Simplify race condition handling comments - Remove excessive method documentation for simple operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -13,31 +13,23 @@ from ..base import MeetingData, VideoPlatformClient
|
||||
|
||||
|
||||
class JitsiMeetingData(MeetingData):
|
||||
"""Jitsi-specific meeting data with typed extra_data."""
|
||||
|
||||
@property
|
||||
def user_jwt(self) -> str:
|
||||
"""JWT token for regular users."""
|
||||
return self.extra_data.get("user_jwt", "")
|
||||
|
||||
@property
|
||||
def host_jwt(self) -> str:
|
||||
"""JWT token for moderators."""
|
||||
return self.extra_data.get("host_jwt", "")
|
||||
|
||||
@property
|
||||
def domain(self) -> str:
|
||||
"""Jitsi domain."""
|
||||
return self.extra_data.get("domain", "")
|
||||
|
||||
|
||||
class JitsiClient(VideoPlatformClient):
|
||||
"""Jitsi Meet video platform implementation."""
|
||||
|
||||
PLATFORM_NAME = VideoPlatform.JITSI
|
||||
|
||||
def _generate_jwt(self, room: str, moderator: bool, exp: datetime) -> str:
|
||||
"""Generate JWT token for Jitsi Meet room access."""
|
||||
if not settings.JITSI_JWT_SECRET:
|
||||
raise ValueError("JITSI_JWT_SECRET is required for JWT generation")
|
||||
|
||||
@@ -64,15 +56,11 @@ class JitsiClient(VideoPlatformClient):
|
||||
async def create_meeting(
|
||||
self, room_name_prefix: str, end_date: datetime, room: Room
|
||||
) -> JitsiMeetingData:
|
||||
"""Create a Jitsi Meet room with JWT authentication."""
|
||||
# Generate unique room name
|
||||
jitsi_room = f"reflector-{room.name}-{generate_uuid4()}"
|
||||
|
||||
# Generate JWT tokens
|
||||
user_jwt = self._generate_jwt(room=jitsi_room, moderator=False, exp=end_date)
|
||||
host_jwt = self._generate_jwt(room=jitsi_room, moderator=True, exp=end_date)
|
||||
|
||||
# Build room URLs with JWT tokens
|
||||
room_url = f"https://{settings.JITSI_DOMAIN}/{jitsi_room}?jwt={user_jwt}"
|
||||
host_room_url = f"https://{settings.JITSI_DOMAIN}/{jitsi_room}?jwt={host_jwt}"
|
||||
|
||||
@@ -90,7 +78,6 @@ class JitsiClient(VideoPlatformClient):
|
||||
)
|
||||
|
||||
async def get_room_sessions(self, room_name: str) -> Dict[str, Any]:
|
||||
"""Get room sessions (mock implementation - Jitsi doesn't provide sessions API)."""
|
||||
return {
|
||||
"roomName": room_name,
|
||||
"sessions": [
|
||||
@@ -104,17 +91,14 @@ class JitsiClient(VideoPlatformClient):
|
||||
}
|
||||
|
||||
async def delete_room(self, room_name: str) -> bool:
|
||||
"""Delete room (no-op - Jitsi rooms auto-expire with JWT expiration)."""
|
||||
return True
|
||||
|
||||
async def upload_logo(self, room_name: str, logo_path: str) -> bool:
|
||||
"""Upload logo (no-op - custom branding handled via Jitsi server config)."""
|
||||
return True
|
||||
|
||||
def verify_webhook_signature(
|
||||
self, body: bytes, signature: str, timestamp: Optional[str] = None
|
||||
) -> bool:
|
||||
"""Verify webhook signature for Prosody event-sync webhooks."""
|
||||
if not signature or not self.config.webhook_secret:
|
||||
return False
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ from ..base import MeetingData, VideoPlatformClient
|
||||
|
||||
|
||||
class WherebyClient(VideoPlatformClient):
|
||||
"""Whereby video platform implementation."""
|
||||
|
||||
PLATFORM_NAME = VideoPlatform.WHEREBY
|
||||
|
||||
def __init__(self, config):
|
||||
@@ -27,7 +25,6 @@ class WherebyClient(VideoPlatformClient):
|
||||
async def create_meeting(
|
||||
self, room_name_prefix: str, end_date: datetime, room: Room
|
||||
) -> MeetingData:
|
||||
"""Create a Whereby meeting room."""
|
||||
data = {
|
||||
"isLocked": room.is_locked,
|
||||
"roomNamePrefix": room_name_prefix,
|
||||
@@ -72,7 +69,6 @@ class WherebyClient(VideoPlatformClient):
|
||||
)
|
||||
|
||||
async def get_room_sessions(self, room_name: str) -> Dict[str, Any]:
|
||||
"""Get session information for a room."""
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(
|
||||
f"{self.config.api_url}/insights/room-sessions?roomName={room_name}",
|
||||
@@ -83,11 +79,9 @@ class WherebyClient(VideoPlatformClient):
|
||||
return response.json()
|
||||
|
||||
async def delete_room(self, room_name: str) -> bool:
|
||||
"""Delete a room. Whereby rooms auto-expire, so this is a no-op."""
|
||||
return True
|
||||
|
||||
async def upload_logo(self, room_name: str, logo_path: str) -> bool:
|
||||
"""Upload a logo to the room."""
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
with open(logo_path, "rb") as f:
|
||||
@@ -107,7 +101,6 @@ class WherebyClient(VideoPlatformClient):
|
||||
def verify_webhook_signature(
|
||||
self, body: bytes, signature: str, timestamp: Optional[str] = None
|
||||
) -> bool:
|
||||
"""Verify webhook signature for Whereby webhooks."""
|
||||
if not signature or not self.config.webhook_secret:
|
||||
return False
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ router = APIRouter()
|
||||
|
||||
|
||||
def parse_datetime_with_timezone(iso_string: str) -> datetime:
|
||||
"""Parse ISO datetime string and ensure timezone awareness (defaults to UTC if naive)."""
|
||||
dt = datetime.fromisoformat(iso_string)
|
||||
if dt.tzinfo is None:
|
||||
dt = dt.replace(tzinfo=timezone.utc)
|
||||
@@ -202,11 +201,9 @@ async def rooms_create_meeting(
|
||||
if meeting is None:
|
||||
end_date = current_time + timedelta(hours=8)
|
||||
|
||||
# Use platform abstraction to create meeting
|
||||
platform = room.platform
|
||||
client = create_platform_client(platform)
|
||||
|
||||
# Use platform client
|
||||
platform_meeting = await client.create_meeting("", end_date=end_date, room=room)
|
||||
await client.upload_logo(platform_meeting.room_name, "./images/logo.png")
|
||||
|
||||
@@ -215,11 +212,9 @@ async def rooms_create_meeting(
|
||||
"room_name": platform_meeting.room_name,
|
||||
"room_url": platform_meeting.room_url,
|
||||
"host_room_url": platform_meeting.host_room_url,
|
||||
"start_date": current_time, # Platform client provides datetime objects
|
||||
"start_date": current_time,
|
||||
"end_date": end_date,
|
||||
}
|
||||
|
||||
# Now try to save to database
|
||||
try:
|
||||
meeting = await meetings_controller.create(
|
||||
id=meeting_data["meeting_id"],
|
||||
@@ -232,8 +227,6 @@ async def rooms_create_meeting(
|
||||
room=room,
|
||||
)
|
||||
except (asyncpg.exceptions.UniqueViolationError, sqlite3.IntegrityError):
|
||||
# Another request already created a meeting for this room
|
||||
# Log this race condition occurrence
|
||||
logger.info(
|
||||
"Race condition detected for room %s - fetching existing meeting",
|
||||
room.name,
|
||||
@@ -243,13 +236,10 @@ async def rooms_create_meeting(
|
||||
meeting_data["meeting_id"],
|
||||
room.name,
|
||||
)
|
||||
|
||||
# Fetch the meeting that was created by the other request
|
||||
meeting = await meetings_controller.get_active(
|
||||
room=room, current_time=current_time
|
||||
)
|
||||
if meeting is None:
|
||||
# Edge case: meeting was created but expired/deleted between checks
|
||||
logger.error(
|
||||
"Meeting disappeared after race condition for room %s", room.name
|
||||
)
|
||||
@@ -268,7 +258,6 @@ async def rooms_test_webhook(
|
||||
room_id: str,
|
||||
user: Annotated[Optional[auth.UserInfo], Depends(auth.current_user_optional)],
|
||||
):
|
||||
"""Test webhook configuration by sending a sample payload."""
|
||||
user_id = user["sub"] if user else None
|
||||
|
||||
room = await rooms_controller.get_by_id(room_id)
|
||||
|
||||
Reference in New Issue
Block a user