Skip to content
10 changes: 8 additions & 2 deletions app/eventyay/config/next_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.utils.translation import gettext_lazy as _
from kombu import Queue
from pycountry import currencies
from pydantic import Field, HttpUrl
from pydantic import Field, HttpUrl, model_validator
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model_validator import is not used anywhere in this file. According to the PR description, a model validator should be implemented to automatically default short_url to site_url when not explicitly configured, but no such validator has been added. Either implement the validator or remove this unused import.

Suggested change
from pydantic import Field, HttpUrl, model_validator
from pydantic import Field, HttpUrl

Copilot uses AI. Check for mistakes.
from pydantic_settings import BaseSettings as _BaseSettings
from pydantic_settings import PydanticBaseSettingsSource, SettingsConfigDict, TomlConfigSettingsSource
from redis.asyncio.retry import Retry
Expand Down Expand Up @@ -128,7 +128,7 @@ class BaseSettings(_BaseSettings):
# Override it to match the domain the website is running on,
# or you will get "DisallowedHost" error.
site_url: HttpUrl = 'http://localhost:8000'
short_url: HttpUrl = 'http://localhost:8000'
short_url: HttpUrl | None = None
talk_hostname: str = 'http://localhost:8000'
sentry_dsn: str = ''
instance_name: str = 'eventyay'
Expand All @@ -146,6 +146,12 @@ class BaseSettings(_BaseSettings):
zoom_key: str = ''
zoom_secret: str = ''
control_secret: str = ''

@model_validator(mode='after')
def default_short_url(self) -> 'BaseSettings':
if self.short_url is None:
self.short_url = self.site_url
return self
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model_validator is placed in the middle of field definitions, between control_secret and statsd_host. For better code organization and readability, consider moving all validators to the end of the class after all field definitions, or grouping them with related fields.

Copilot uses AI. Check for mistakes.
statsd_host: str = ''
statsd_port: int = 8125
statsd_prefix: str = 'eventyay'
Expand Down
45 changes: 29 additions & 16 deletions app/eventyay/features/live/modules/bbb.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.db.utils import IntegrityError
from eventyay.core.permissions import Permission
from eventyay.base.services.bbb import BBBService
from eventyay.features.live.decorators import command, room_action
Expand All @@ -20,15 +21,20 @@ async def room_url(self, body):
service = BBBService(self.consumer.event)
if not self.consumer.user.profile.get("display_name"):
raise ConsumerException("bbb.join.missing_profile")
url = await service.get_join_url_for_room(
self.room,
self.consumer.user,
moderator=await self.consumer.event.has_permission_async(
user=self.consumer.user,
permission=Permission.ROOM_BBB_MODERATE,
room=self.room,
),
)
try:
url = await service.get_join_url_for_room(
self.room,
self.consumer.user,
moderator=await self.consumer.event.has_permission_async(
user=self.consumer.user,
permission=Permission.ROOM_BBB_MODERATE,
room=self.room,
),
)
except IntegrityError:
# This happens in dev environment when no BBB server is configured
raise ConsumerException("bbb.failed")
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching IntegrityError here is too broad and may mask other database integrity issues. The actual problem occurs when choose_server() returns None (no BBB servers configured), which causes the BBBCall.server foreign key constraint to fail. Consider catching a more specific exception or checking if server is None in the get_create_params_for_room function instead.

Copilot uses AI. Check for mistakes.

if not url:
raise ConsumerException("bbb.failed")
await self.consumer.send_success({"url": url})
Expand All @@ -38,10 +44,14 @@ async def call_url(self, body):
service = BBBService(self.consumer.event)
if not self.consumer.user.profile.get("display_name"):
raise ConsumerException("bbb.join.missing_profile")
url = await service.get_join_url_for_call_id(
body.get("call"),
self.consumer.user,
)
try:
url = await service.get_join_url_for_call_id(
body.get("call"),
self.consumer.user,
)
except IntegrityError:
raise ConsumerException("bbb.failed")
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching IntegrityError here is too broad and may mask other database integrity issues. The actual problem occurs when choose_server() returns None (no BBB servers configured), which causes the BBBCall.server foreign key constraint to fail. Consider catching a more specific exception or checking if server is None in the get_create_params_for_call_id function instead.

Suggested change
try:
url = await service.get_join_url_for_call_id(
body.get("call"),
self.consumer.user,
)
except IntegrityError:
raise ConsumerException("bbb.failed")
url = await service.get_join_url_for_call_id(
body.get("call"),
self.consumer.user,
)

Copilot uses AI. Check for mistakes.

if not url:
raise ConsumerException("bbb.failed")
await self.consumer.send_success({"url": url})
Expand All @@ -53,7 +63,10 @@ async def call_url(self, body):
)
async def recordings(self, body):
service = BBBService(self.consumer.event)
recordings = await service.get_recordings_for_room(
self.room,
)
try:
recordings = await service.get_recordings_for_room(
self.room,
)
except IntegrityError:
recordings = []
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space before 'recordings' causing incorrect indentation. This line should align with the 'except' block above it.

Suggested change
recordings = []
recordings = []

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recordings method is unlikely to raise IntegrityError since it doesn't create or update any BBBCall records - it only queries for recordings. The get_recordings_for_room method already has comprehensive exception handling that returns an empty list on errors. This try-except block appears unnecessary and may give a false sense of error handling.

Suggested change
try:
recordings = await service.get_recordings_for_room(
self.room,
)
except IntegrityError:
recordings = []
recordings = await service.get_recordings_for_room(
self.room,
)

Copilot uses AI. Check for mistakes.
await self.consumer.send_success({"results": recordings})