From 5070cf8191dca981668654be41086ae9596140ef Mon Sep 17 00:00:00 2001 From: Vladimir Date: Tue, 4 Nov 2025 19:26:33 +0500 Subject: [PATCH] feat(verification): add infrastructure for user verification - **FSM States:** Added `VerificationStates` to manage the dialog flow. - **Services:** Implemented `get_or_create_user` and `verify_student` to encapsulate business logic. - **Middleware Chain:** Refactored the middleware to a clean, sequential chain (`Database`, `TelegramUser`, `Registration`) where each has a single responsibility. - **Verification Status:** Introduced a `VerificationStatus` enum for clear and type-safe results from the verification service. --- src/bot/services/verification.py | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/bot/services/verification.py b/src/bot/services/verification.py index df86b84..cf729ca 100644 --- a/src/bot/services/verification.py +++ b/src/bot/services/verification.py @@ -1,5 +1,4 @@ __all__ = [ - "check_registration_status", "verify_student" ] @@ -13,32 +12,11 @@ from src.database.models import Student, TelegramUser from .types.verification_statuses import VerificationStatus -async def check_registration_status( - tg_id: int, - session: AsyncSession, -) -> bool: - """ - Checks if a tg user is linked to a university member. - - Args: - tg_id (int): user's telegram id. - session (AsyncSession): database session. - - Returns: - bool: True if the user is registered (linked), otherwise False. - """ - query = select(TelegramUser).where(TelegramUser.id == tg_id) - result = await session.execute(query) - user = result.scalar_one_or_none() - - return user is not None and user.university_member_id is not None - - async def verify_student( tg_user: TelegramUser, name: str, student_id: int, - group_id: int, + group_id: str, session: AsyncSession, ) -> VerificationStatus: """