chore: snapshot before HartOMat rebrand
This commit is contained in:
@@ -99,12 +99,21 @@ async def send_message(
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail=str(exc))
|
||||
except Exception as exc:
|
||||
error_msg = str(exc)
|
||||
error_code = None
|
||||
# Extract meaningful error from OpenAI exceptions
|
||||
if hasattr(exc, 'message'):
|
||||
error_msg = exc.message
|
||||
elif hasattr(exc, 'body') and isinstance(exc.body, dict):
|
||||
error_msg = exc.body.get('error', {}).get('message', error_msg)
|
||||
if hasattr(exc, 'body') and isinstance(exc.body, dict):
|
||||
err = exc.body.get('error', {})
|
||||
error_code = err.get('code')
|
||||
error_msg = err.get('message', error_msg)
|
||||
logger.error("Chat error: %s", error_msg)
|
||||
# Content filter violation → return 422 with user-friendly message
|
||||
if error_code == 'content_filter':
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="Deine Nachricht wurde vom Azure Content Filter blockiert. Bitte formuliere sie um.",
|
||||
)
|
||||
raise HTTPException(status_code=500, detail=f"AI error: {error_msg[:500]}")
|
||||
except Exception as exc:
|
||||
logger.exception("Chat error for user %s", user.id)
|
||||
|
||||
@@ -212,6 +212,50 @@ async def stream_render_log(
|
||||
from fastapi import status as http_status
|
||||
|
||||
|
||||
@router.post("/activity/dismiss-failed", status_code=http_status.HTTP_200_OK)
|
||||
async def dismiss_all_failed(
|
||||
user: User = Depends(require_admin_or_pm),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Reset all failed render jobs and CAD files so they stop showing as failures."""
|
||||
from sqlalchemy import update as sql_update
|
||||
|
||||
render_result = await db.execute(
|
||||
sql_update(OrderLine)
|
||||
.where(OrderLine.render_status == "failed")
|
||||
.values(render_status="cancelled")
|
||||
)
|
||||
cad_result = await db.execute(
|
||||
sql_update(CadFile)
|
||||
.where(CadFile.processing_status == ProcessingStatus.failed)
|
||||
.values(processing_status=ProcessingStatus.pending)
|
||||
)
|
||||
await db.commit()
|
||||
return {"dismissed_renders": render_result.rowcount, "dismissed_cad": cad_result.rowcount}
|
||||
|
||||
|
||||
@router.post("/activity/dismiss-render/{order_line_id}", status_code=http_status.HTTP_200_OK)
|
||||
async def dismiss_single_failed_render(
|
||||
order_line_id: str,
|
||||
user: User = Depends(require_admin_or_pm),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Dismiss a single failed render job by setting its status to 'cancelled'."""
|
||||
result = await db.execute(
|
||||
select(OrderLine).where(
|
||||
OrderLine.id == order_line_id,
|
||||
OrderLine.render_status == "failed",
|
||||
)
|
||||
)
|
||||
line = result.scalar_one_or_none()
|
||||
if not line:
|
||||
raise HTTPException(404, detail="Failed render job not found")
|
||||
|
||||
line.render_status = "cancelled"
|
||||
await db.commit()
|
||||
return {"dismissed": order_line_id}
|
||||
|
||||
|
||||
@router.post("/activity/{cad_file_id}/reprocess", status_code=http_status.HTTP_202_ACCEPTED)
|
||||
async def reprocess_cad_file(
|
||||
cad_file_id: str,
|
||||
|
||||
Reference in New Issue
Block a user