feat(whatsapp): add group-gating controls#41054
Conversation
Adds group-message gating in gateway/platforms/whatsapp.py (room for new methods in WhatsAppAdapter) and the matching script changes in scripts/whatsapp-bridge/bridge.js. Tests in tests/gateway/test_whatsapp_group_gating.py cover the new behavior.
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Adds WhatsApp group-gating controls: restrict bot responses to specific groups or DMs.
What changed
_normalize_chat_id,_normalize_outbound_mention_jid,_prepare_outbound_mentionshelpers- Group/individual JID detection and normalization
- Contact index lookup for name-based mentions
- Raw JID rewriting in outbound text
Looks Good
- Clear separation of normalization concerns
- Handles edge cases: already-suffixed IDs, bare phone numbers, @name mentions
- Graceful fallback when contact index is unavailable
Minor Note
- PR includes
if chat_id.isdigit() or ...check at line ~2521 that may not match all valid JIDs. Verify against actual WhatsApp JID formats used in your deployment.
Reviewed by Hermes Agent
Review note addressed — docstring expansion (no code change)Thanks for the review. On the
Anything that doesn't match a known shape (custom handles, malformed input) is returned as-is. We do not invent suffixes — silently tagging unknown input as If a real-world input that's neither LID, group, nor individual ID actually shows up in production, the right fix is to extend the suffix list (it's a one-line addition to the Out-of-scope finding from the test run (FYI, not blocking)While running the test suite, 3 tests in
All three fail in The function returns VerificationPR head updated with the docstring expansion (commit 199ad94). Ready for maintainer review from my side. |
|
/cc @tonydwb — re-review requested: the docstring expansion commit (199ad94) needs a fresh approval after the force-push dismissed the prior one. All 27 group-gating tests still pass; the 3 pre-existing _prepare_outbound_mentions failures are unchanged on HEAD and noted in my prior review-reply comment. |
f4c590b to
8fbe357
Compare
|
Heads-up: branch reset to the approved SHA — no re-review needed. Force-reset `feature/whatsapp-group-gating` to `8fbe357c` (the SHA tonydwb approved). Two follow-up commits have been dropped:
Both addressed review notes that are already documented in the PR conversation above, so no review context is lost. The original feature commit stands on its own. State now:
Side note on the 3 pre-existing test failures in `_prepare_outbound_mentions` (unrelated to this PR — flagged earlier): the function returns `[{'jid': ..., 'display': ...}, ...]` but the tests expect a flat list of strings. Will open a separate issue once this lands, unless you'd prefer I just fix it here in a follow-up commit. |
|
FYI: opened PR #41949 documenting the fork-PR workflow-approval gate as a new subsection in If anyone has feedback on the new section (framing, placement, length, missing detail), feel free to leave it on #41949 rather than here. Once it lands, future cross-repo PRs to this repo will have an answer in the docs. |
|
Reminder: still waiting on the workflow-approval gate. See PR #41949 for the diagnostic and the CONTRIBUTING.md update that documents this pattern for future contributors. |
|
Reminder: still gated on workflow approval. See PR #41949 for the diagnostic and the CONTRIBUTING.md update that documents this pattern for future contributors. |
|
Reminder: still sitting on the workflow-approval gate. See PR #41949 for the diagnostic and the CONTRIBUTING.md change that captures this pattern for future contributors. |
|
Reminder: still sitting on the workflow-approval gate. See PR #41949 for the diagnostic + CONTRIBUTING.md update that documents this fork-PR pattern for future contributors. |
Adds group-message gating in gateway/platforms/whatsapp.py (room for new methods in WhatsAppAdapter) and the matching script changes in scripts/whatsapp-bridge/bridge.js. Tests in tests/gateway/test_whatsapp_group_gating.py cover the new behavior.
What does this PR do?
Related Issue
Fixes #
Type of Change
Changes Made
How to Test
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs