Skip to content

feat: integrate profile completeness check into captcha verification#9

Open
rezhajulio wants to merge 2 commits intomainfrom
feat/captcha-profile-check
Open

feat: integrate profile completeness check into captcha verification#9
rezhajulio wants to merge 2 commits intomainfrom
feat/captcha-profile-check

Conversation

@rezhajulio
Copy link
Copy Markdown
Owner

Summary

Combines captcha verification with a mandatory profile completeness check (photo + username) before unrestricting new members.

Changes

Captcha + Profile Check Integration

  • When a user clicks the captcha button, their profile is checked first
  • If incomplete, an alert shows what's missing (photo, username, or both) — user can retry
  • Timeout job is preserved until profile check passes, preventing users from getting stuck
  • Welcome message updated to inform users about profile requirements upfront

Handler Hardening

  • Added parse guard for malformed callback data (ValueError/IndexError)
  • Moved timeout job cancellation after successful unrestrict + DB cleanup (fixes bug where failed unrestrict would leave user stuck with no timeout)
  • Wrapped DB finalization in try/except to prevent unanswered callbacks

Test Improvements

  • Replaced fragile AsyncMock(is_complete=...) with real ProfileCheckResult dataclass in all mocks
  • Added tests: malformed callback data, unrestrict failure preserving timeout, incomplete profile (single/both missing), profile check API exception

Flow

  1. User joins → restricted → captcha message sent
  2. User clicks button → profile checked
  3. If incomplete → alert with missing items, timeout stays active
  4. If complete → unrestrict → cleanup DB → cancel timeout → success message

Tests: 555 passed, ~99.9% coverage

- Update captcha welcome message to inform users about profile requirements
- Add profile completeness check (photo + username) in captcha callback handler
- Reject verification with alert if profile is incomplete, keeping timeout active
- Fix double query.answer() bug — each code path now answers exactly once
- Add CAPTCHA_INCOMPLETE_PROFILE_MESSAGE constant for rejection alert
- Update and add tests for new captcha+profile flow (553 tests, 99% coverage)
- Add parse guard for malformed callback data (ValueError/IndexError)
- Move timeout job cancellation after successful unrestrict + DB cleanup
- Wrap DB finalization in try/except to prevent unanswered callbacks
- Replace AsyncMock with ProfileCheckResult dataclass in all test mocks
- Add tests for malformed callback data and unrestrict failure preserving timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant