Add telegram bot

This commit is contained in:
2025-12-16 20:06:16 +07:00
parent 9fd93a185c
commit 412de3bf05
32 changed files with 1721 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ from sqlalchemy.orm import selectinload
from app.api.deps import DbSession, CurrentUser
from app.models import (
Assignment, AssignmentStatus, Participant, Challenge, User,
Assignment, AssignmentStatus, Participant, Challenge, User, Marathon,
Dispute, DisputeStatus, DisputeComment, DisputeVote,
)
from app.schemas import (
@@ -19,6 +19,7 @@ from app.schemas import (
)
from app.schemas.user import UserPublic
from app.services.storage import storage_service
from app.services.telegram_notifier import telegram_notifier
router = APIRouter(tags=["assignments"])
@@ -345,6 +346,17 @@ async def create_dispute(
await db.commit()
await db.refresh(dispute)
# Send notification to assignment owner
result = await db.execute(select(Marathon).where(Marathon.id == marathon_id))
marathon = result.scalar_one_or_none()
if marathon:
await telegram_notifier.notify_dispute_raised(
db,
user_id=assignment.participant.user_id,
marathon_title=marathon.title,
challenge_title=assignment.challenge.title
)
# Load relationships for response
result = await db.execute(
select(Dispute)