update audio-deleted flow

This commit is contained in:
Igor Loskutov
2025-06-18 15:43:34 -04:00
parent 6cb6d90b9a
commit c23e0e07ef
15 changed files with 282 additions and 76 deletions

View File

@@ -43,6 +43,10 @@ def range_requests_response(
):
"""Returns StreamingResponse using Range Requests of a given file"""
if not os.path.exists(file_path):
from fastapi import HTTPException
raise HTTPException(status_code=404, detail="File not found")
file_size = os.stat(file_path).st_size
range_header = request.headers.get("range")

View File

@@ -65,6 +65,7 @@ class GetTranscript(BaseModel):
source_kind: SourceKind
room_id: str | None = None
room_name: str | None = None
audio_deleted: bool | None = None
class CreateTranscript(BaseModel):
@@ -82,6 +83,7 @@ class UpdateTranscript(BaseModel):
share_mode: Optional[Literal["public", "semi-private", "private"]] = Field(None)
participants: Optional[list[TranscriptParticipant]] = Field(None)
reviewed: Optional[bool] = Field(None)
audio_deleted: Optional[bool] = Field(None)
class DeletionStatus(BaseModel):

View File

@@ -86,8 +86,11 @@ async def transcript_get_audio_mp3(
headers=resp.headers,
)
if transcript.audio_deleted:
raise HTTPException(status_code=404, detail="Audio unavailable due to privacy settings")
if not transcript.audio_mp3_filename.exists():
raise HTTPException(status_code=500, detail="Audio not found")
raise HTTPException(status_code=404, detail="Audio file not found")
truncated_id = str(transcript.id).split("-")[0]
filename = f"recording_{truncated_id}.mp3"