Skip to content

feat(whatsapp): access control integration (WHATSAPP-001 Phase 2, #299 follow-up) #467

Closed

Description

@vybe

Summary

Phase 2 follow-up to WHATSAPP-001 (#299). Wire WhatsApp into the unified cross-channel access control system (#311) so WhatsApp identities can be gated by the same agent_sharing / access_requests primitives as Telegram/Slack/web.

Phase 1 shipped the schema columns (whatsapp_chat_links.verified_email, whatsapp_chat_links.verified_at) up-front — this phase is pure application-only code.

Context

Today a WhatsApp user has no way to prove email identity, so they fall through to the legacy permissive path in message_router._handle_message_inner. That's fine for Phase 1 (agents opt in via whatsapp_bindings), but it means:

  • require_email policy has no effect on WhatsApp
  • open_access policy has no effect on WhatsApp
  • The approval queue (access_requests) never sees WhatsApp senders
  • proactive_message_service._deliver_via_channel cannot route to a WhatsApp-verified user (currently raises ValueError: Unknown channel: whatsapp)

Phase 2 closes the gap so WhatsApp gates uniformly with Telegram + Slack + web.

Acceptance Criteria

  • WhatsAppAdapter.is_command(message) detects /login, /logout, /whoami — mirrors Telegram's pattern
  • WhatsAppAdapter.handle_command(message) implements the /login <email> → email verification code → /login <6-digit-code> flow, writing verified_email to whatsapp_chat_links on success
  • WhatsAppAdapter.resolve_verified_email(message) already exists (Phase 1) — verify it's exercised by the router gate
  • WhatsAppAdapter.prompt_auth(message, agent_name, bot_token) sends a WhatsApp-native prompt when the agent requires a verified email
  • Pending-login state stored in Redis with 10-minute TTL (matches Telegram pattern)
  • On successful verification: run the same access gate as message_router to tell the user "you can chat" OR "pending approval" — no two-step UX surprise
  • proactive_message_service._deliver_via_channel gains a whatsapp branch + _deliver_whatsapp() helper
  • access_requests.channel now includes 'whatsapp' as a valid value; confirm DB schema comment in architecture.md
  • Unit tests: /login with email, /login with code (valid/invalid/expired), access-gate outcomes (shared/open_access/restricted), /logout, /whoami
  • Feature flow doc updated: docs/memory/feature-flows/whatsapp-integration.md + docs/memory/feature-flows/unified-channel-access-control.md

Technical Notes

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p2theme-channelstype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions