feat(mini): add voice recording compatibility logging

This commit is contained in:
stu2not
2026-05-25 17:26:57 +08:00
parent 2639ab06ab
commit 5d86ee5826
3 changed files with 345 additions and 16 deletions

View File

@@ -455,15 +455,37 @@ async def create_child_voice_message_for_parent(
duration_ms: int = Form(..., ge=0),
client_msg_id: str = Form(..., min_length=1, max_length=64),
transcript_text: str | None = Form(default=None, max_length=1000),
audio_format: str | None = Form(default=None, max_length=16),
mime_type: str | None = Form(default=None, max_length=64),
current_user_id: int = Depends(get_current_user_id),
) -> ConversationMessageCreateResponse:
try:
content = await file.read()
normalized_format = (audio_format or "").strip().lower().lstrip(".")
filename = file.filename or (f"voice.{normalized_format}" if normalized_format else None)
content_type = (mime_type or "").strip() or file.content_type
logger.info(
"parent child voice upload received",
extra={
"event": "parent_child_voice_upload_receive",
"request_id": getattr(request.state, "request_id", None),
"user_id": current_user_id,
"child_id": child_id,
"file_name": file.filename,
"effective_file_name": filename,
"file_content_type": file.content_type,
"client_mime_type": mime_type,
"effective_content_type": content_type,
"client_audio_format": audio_format,
"duration_ms": duration_ms,
"size_bytes": len(content),
},
)
result = await im_service.create_parent_child_voice_message(
parent_user_id=current_user_id,
child_id=child_id,
filename=file.filename,
content_type=file.content_type,
filename=filename,
content_type=content_type,
content=content,
media_duration_ms=duration_ms,
media_transcript_text=transcript_text,