diff --git a/backend/app/routers/connections.py b/backend/app/routers/connections.py index a1e88da..24d9126 100644 --- a/backend/app/routers/connections.py +++ b/backend/app/routers/connections.py @@ -10,7 +10,7 @@ Security: """ import asyncio import logging -from datetime import date as date_type, datetime, timedelta, timezone +from datetime import date as date_type, datetime, timedelta from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Path, Query, Request from sqlalchemy import delete, select, func, and_, update @@ -131,16 +131,6 @@ async def send_connection_request( current_user: User = Depends(get_current_user), ): """Send a connection request to another user.""" - try: - return await _send_request_impl(body, request, background_tasks, db, current_user) - except HTTPException: - raise - except Exception as exc: - logger.error("send_connection_request UNHANDLED: %s", exc, exc_info=True) - raise HTTPException(status_code=500, detail=f"DEBUG: {type(exc).__name__}: {exc}") - - -async def _send_request_impl(body, request, background_tasks, db, current_user): # Resolve target result = await db.execute( select(User).where(User.umbral_name == body.umbral_name) @@ -194,7 +184,7 @@ async def _send_request_impl(body, request, background_tasks, db, current_user): raise HTTPException(status_code=409, detail="A pending request already exists") # Per-receiver cap: max 5 pending requests within 10 minutes - ten_min_ago = datetime.now(timezone.utc) - timedelta(minutes=10) + ten_min_ago = datetime.now() - timedelta(minutes=10) pending_count = await db.scalar( select(func.count()) .select_from(ConnectionRequest) @@ -388,7 +378,7 @@ async def _respond_to_request_inner( db: AsyncSession, current_user: User, ) -> RespondAcceptResponse | RespondRejectResponse: - now = datetime.now(timezone.utc) + now = datetime.now() # Atomic update — only succeeds if status is still 'pending' and receiver is current user result = await db.execute( @@ -575,7 +565,7 @@ async def cancel_request( current_user: User = Depends(get_current_user), ): """Cancel an outgoing connection request. Atomic via UPDATE...WHERE status='pending'.""" - now = datetime.now(timezone.utc) + now = datetime.now() # Atomic update — only succeeds if sender is current user and status is still pending result = await db.execute(