Группы: приглашения вместо авто-добавления (согласиться/отказаться)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"""Входящие приглашения игрока: список, принятие, отклонение."""
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlmodel import Session
|
||||
|
||||
from app.auth.deps import get_current_user
|
||||
from app.db.session import get_session
|
||||
from app.models import User
|
||||
from app.schemas import api as s
|
||||
from app.services import invitation_service
|
||||
|
||||
router = APIRouter(prefix="/invitations", tags=["invitations"])
|
||||
|
||||
|
||||
@router.get("", response_model=list[s.InvitationRead])
|
||||
def my_invitations(
|
||||
session: Session = Depends(get_session),
|
||||
user: User = Depends(get_current_user),
|
||||
) -> list[dict]:
|
||||
return invitation_service.list_for_user(session, user.id) # type: ignore[arg-type]
|
||||
|
||||
|
||||
@router.post("/{invitation_id}/accept", response_model=s.OkResponse)
|
||||
def accept_invitation(
|
||||
invitation_id: int,
|
||||
session: Session = Depends(get_session),
|
||||
user: User = Depends(get_current_user),
|
||||
) -> s.OkResponse:
|
||||
invitation_service.accept(session, user, invitation_id)
|
||||
return s.OkResponse()
|
||||
|
||||
|
||||
@router.post("/{invitation_id}/decline", response_model=s.OkResponse)
|
||||
def decline_invitation(
|
||||
invitation_id: int,
|
||||
session: Session = Depends(get_session),
|
||||
user: User = Depends(get_current_user),
|
||||
) -> s.OkResponse:
|
||||
invitation_service.decline(session, user, invitation_id)
|
||||
return s.OkResponse()
|
||||
Reference in New Issue
Block a user