From 309c5328119244fea00d6dc8f256ed02f5163060 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Tue, 30 Dec 2025 19:02:10 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(backend)=20submit=20screen=20recordin?= =?UTF-8?q?gs=20to=20the=20summary=20microservice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Screen recording are MP4 files containing video) The current approach is suboptimal: the microservice will later be updated to extract audio paths from video, which can be heavy to send to the Whisper service. This implementation is straightforward, but the notification service is now handling many responsibilities through conditional logic. A refactor with a more configurable approach (mapping attributes to processing steps via settings) would be cleaner and easier to maintain. For now, this works; further improvements can come later. I follow the KISS principle, and try to make this new feature implemented with the lesser impact on the codebase. This isn’t perfect. --- .../core/recording/event/notification.py | 7 ++++++- .../recording/event/test_notification.py | 20 +++++++++++++++++++ src/summary/summary/core/config.py | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/backend/core/recording/event/notification.py b/src/backend/core/recording/event/notification.py index 89ea5111..f7fe1d57 100644 --- a/src/backend/core/recording/event/notification.py +++ b/src/backend/core/recording/event/notification.py @@ -26,7 +26,12 @@ class NotificationService: return self._notify_summary_service(recording) if recording.mode == models.RecordingModeChoices.SCREEN_RECORDING: - return self._notify_user_by_email(recording) + summary_success = True + if recording.options.get("transcribe", False): + summary_success = self._notify_summary_service(recording) + + email_success = self._notify_user_by_email(recording) + return email_success and summary_success logger.error( "Unknown recording mode %s for recording %s", diff --git a/src/backend/core/tests/recording/event/test_notification.py b/src/backend/core/tests/recording/event/test_notification.py index 856cea52..0cfd6059 100644 --- a/src/backend/core/tests/recording/event/test_notification.py +++ b/src/backend/core/tests/recording/event/test_notification.py @@ -60,6 +60,26 @@ def test_notify_external_services_screen_recording_mode(mock_notify_email): mock_notify_email.assert_called_once_with(recording) +@mock.patch.object(NotificationService, "_notify_summary_service", return_value=True) +@mock.patch.object(NotificationService, "_notify_user_by_email", return_value=True) +def test_notify_external_services_screen_recording_mode_with_transcribe( + mock_notify_email, mock_notify_summary +): + """Test notification routing for screen recording mode with transcribe option.""" + + service = NotificationService() + + recording = factories.RecordingFactory( + mode=models.RecordingModeChoices.SCREEN_RECORDING, options={"transcribe": True} + ) + + result = service.notify_external_services(recording) + + assert result is True + mock_notify_email.assert_called_once_with(recording) + mock_notify_summary.assert_called_once_with(recording) + + def test_notify_external_services_unknown_mode(caplog): """Test notification for unknown recording mode.""" recording = factories.RecordingFactory() diff --git a/src/summary/summary/core/config.py b/src/summary/summary/core/config.py index 2624cced..4e408b25 100644 --- a/src/summary/summary/core/config.py +++ b/src/summary/summary/core/config.py @@ -19,7 +19,7 @@ class Settings(BaseSettings): # Audio recordings recording_max_duration: Optional[int] = None - recording_allowed_extensions: Set[str] = {".ogg"} + recording_allowed_extensions: Set[str] = {".ogg", ".mp4"} # Celery settings celery_broker_url: str = "redis://redis/0"