2025-12-17 00:44:01 +02:00

26 lines
837 B
Python

from fastapi import APIRouter, HTTPException, status, Depends
from app.schemas import LikeResponse
from app.services.like_service import LikeService
from app.auth import get_current_user
router = APIRouter(prefix="/likes", tags=["likes"])
@router.post("/{liked_user_id}", response_model=LikeResponse)
def like_user(
liked_user_id: int,
current_user: dict = Depends(get_current_user)
):
"""Like another user"""
try:
return LikeService.like_user(current_user["user_id"], liked_user_id)
except ValueError as e:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=str(e)
)
@router.get("/matches/list")
def get_matches(current_user: dict = Depends(get_current_user)):
"""Get all matches"""
return LikeService.get_matches(current_user["user_id"])