diff --git a/backend/app/main.py b/backend/app/main.py index 1676533..487343c 100755 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -195,6 +195,7 @@ async def websocket_analyze(websocket: WebSocket): logger.info(f"[MAIN] Authenticated user: {user_claims.get('name', 'unknown')}") # Check role: oversight_admin cannot upload/analyze proofs + current_user_id: Optional[uuid.UUID] = None try: async with _session_factory() as ws_session: ws_user_repo = UserRepository(ws_session) @@ -206,6 +207,7 @@ async def websocket_analyze(websocket: WebSocket): "message": "Oversight Admin has read-only access and cannot analyze proofs." }) continue + current_user_id = ws_user.id if ws_user else None except Exception as role_err: logger.warning(f"[MAIN] Role check failed for client {client_id}: {role_err}") @@ -224,6 +226,7 @@ async def websocket_analyze(websocket: WebSocket): data=data, manager=manager, analysis_service=analysis_service, + current_user_id=current_user_id, ) else: logger.warning(f"[MAIN] Unknown message type: {data.get('type')}") diff --git a/backend/app/websocket/handlers.py b/backend/app/websocket/handlers.py index 1d32f73..31beb32 100755 --- a/backend/app/websocket/handlers.py +++ b/backend/app/websocket/handlers.py @@ -21,6 +21,7 @@ async def handle_analyze_message( data: dict, manager: ConnectionManager, analysis_service: AnalysisService, + current_user_id: Optional[uuid.UUID] = None, ) -> None: """ Handle an 'analyze' message from the client. @@ -229,6 +230,7 @@ async def handle_analyze_message( overall_status=result.overallStatus, file_hash=file_hash, is_identical_file=is_identical_file, + created_by=current_user_id, ) # Auto-create ErrorItem when analysis results in an error