diff --git a/server/reflector/views/transcripts.py b/server/reflector/views/transcripts.py index 27663dc6..02c1aa3e 100644 --- a/server/reflector/views/transcripts.py +++ b/server/reflector/views/transcripts.py @@ -17,6 +17,7 @@ from pydantic import ( import reflector.auth as auth from reflector.db import get_database from reflector.db.recordings import recordings_controller +from reflector.db.rooms import rooms_controller from reflector.db.search import ( DEFAULT_SEARCH_LIMIT, SearchLimit, @@ -473,6 +474,11 @@ async def transcript_get( is_multitrack = await _get_is_multitrack(transcript) + room_name = None + if transcript.room_id: + room = await rooms_controller.get_by_id(transcript.room_id) + room_name = room.name if room else None + participants = [] if transcript.participants: user_ids = [p.user_id for p in transcript.participants if p.user_id is not None] @@ -503,6 +509,7 @@ async def transcript_get( "meeting_id": transcript.meeting_id, "source_kind": transcript.source_kind, "room_id": transcript.room_id, + "room_name": room_name, "audio_deleted": transcript.audio_deleted, "participants": participants, } diff --git a/server/tests/test_transcripts.py b/server/tests/test_transcripts.py index 2c6acc77..9a3ff576 100644 --- a/server/tests/test_transcripts.py +++ b/server/tests/test_transcripts.py @@ -1,5 +1,8 @@ import pytest +from reflector.db.rooms import rooms_controller +from reflector.db.transcripts import transcripts_controller + @pytest.mark.asyncio async def test_transcript_create(client): @@ -182,3 +185,51 @@ async def test_transcript_mark_reviewed(authenticated_client, client): response = await client.get(f"/transcripts/{tid}") assert response.status_code == 200 assert response.json()["reviewed"] is True + + +@pytest.mark.asyncio +async def test_transcript_get_returns_room_name(authenticated_client, client): + """Test that getting a transcript returns its room_name when linked to a room.""" + # Create a room + room = await rooms_controller.add( + name="test-room-for-transcript", + user_id="test-user", + zulip_auto_post=False, + zulip_stream="", + zulip_topic="", + is_locked=False, + room_mode="normal", + recording_type="cloud", + recording_trigger="automatic-2nd-participant", + is_shared=False, + webhook_url="", + webhook_secret="", + ) + + # Create a transcript linked to the room + transcript = await transcripts_controller.add( + name="transcript-with-room", + source_kind="file", + room_id=room.id, + ) + + # Get the transcript and verify room_name is returned + response = await client.get(f"/transcripts/{transcript.id}") + assert response.status_code == 200 + assert response.json()["room_id"] == room.id + assert response.json()["room_name"] == "test-room-for-transcript" + + +@pytest.mark.asyncio +async def test_transcript_get_returns_null_room_name_when_no_room( + authenticated_client, client +): + """Test that room_name is null when transcript has no room.""" + response = await client.post("/transcripts", json={"name": "no-room-transcript"}) + assert response.status_code == 200 + tid = response.json()["id"] + + response = await client.get(f"/transcripts/{tid}") + assert response.status_code == 200 + assert response.json()["room_id"] is None + assert response.json()["room_name"] is None