Skip to content

feat: Chat compliance dry run#224

Merged
danoctua merged 3 commits intodevfrom
feat/chat-compliance-dry-run
Mar 3, 2026
Merged

feat: Chat compliance dry run#224
danoctua merged 3 commits intodevfrom
feat/chat-compliance-dry-run

Conversation

@danoctua
Copy link
Collaborator

@danoctua danoctua commented Mar 3, 2026

Add chat eligibility check dry run

Description

This pull request introduces a "dry run" functionality for the chat management system, which allows community managers to check user compliance against chat rules without actually removing/kicking any users. It also refactors AuthorizationAction.evaluate_chat_members_eligibility so that it doesn't implicitly hide unmanaged users, purely focusing on calculating rules eligibility.

Checklist

Before submitting your pull request, please ensure the following:

  • I have read the contributing guidelines.
  • I ran all tests and they passed successfully.
  • I added/updated documentation (if applicable).
  • I reviewed my own code and followed the project's code style.
  • I included relevant details in the PR description or commit messages.

Changes

  • Change 1: Extracted the hardcoded is_managed and is_full_control chat member filtering into the caller, refactoring AuthorizationAction into evaluate_chat_members_eligibility. It now simply processes whoever is passed to it and returns explicit ChatMemberEligibilityResultDTO objects.
  • Change 2: Added check_chat_members_compliance_dry_run to CommunityManagerUserChatAction. It logs rule evaluation summaries for all valid server members (managed and non-managed), outputting a summary at the end.
  • Change 3: Integrated automatic is_managed toggling directly in CommunityManagerUserChatAction.kick_ineligible_chat_members. If a previously unmanaged user passes an eligibility check in a full-control chat, they forcefully become managed (is_managed = True).
  • Change 4: Added POST /admin/chat/manage/{slug}/control-dry-run endpoint wired to a new Celery task check-target-chat-members-dry-run with a 5-minute Redis-based rate limit cooldown.
  • Change 5: Refactored unit tests in the community_manager module to use test.factories (e.g., TelegramChatUserFactory.with_session(db_session).create(...)) for predictable and robust DB states. Added tests covering the dry-run counting mechanics and the is_managed toggle tagging logic.

How Has This Been Tested?

We tested these changes against the existing suite using the dockerized backend environment.


Thank you for contributing! 🎉

@danoctua danoctua self-assigned this Mar 3, 2026
@danoctua danoctua added the enhancement New feature or request label Mar 3, 2026
@danoctua danoctua merged commit 43e5259 into dev Mar 3, 2026
2 checks passed
@danoctua danoctua deleted the feat/chat-compliance-dry-run branch March 4, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant