Conversation
- Add processFromSelf and processGroups options to WhatsApp connection - Default remains 1:1 from others only; opt-in via Message Filtering UI - For groups, use participant JID for sender identity and reply in group - Schema migration 0013; API filter endpoint accepts optional booleans - UI: Message sources section with checkboxes on WhatsApp Connection page
- Add mark_online_on_connect to whatsapp_connections (default false) - Expose toggle in Phone notifications card on WhatsApp Connection page - Client reads option at init and passes to makeWASocket - When off, phone keeps notifications and unread badges; WAMR still receives messages Co-authored-by: Cursor <[email protected]>
3c164f3 to
94b742f
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a configurable markOnlineOnConnect option to control whether the WhatsApp session appears "online" when WAMR connects. The default is false to preserve phone notifications. It also includes the foundation for processing messages from self and groups (introduced in migration 0013), which appears to be from a dependent feature branch as mentioned in the PR description.
Changes:
- Added database migration 0014 for
mark_online_on_connectcolumn with defaultfalse - Extended backend models, validators, repository, and controllers to handle the new option
- WhatsApp client reads the option from database at initialization and applies it to the Baileys socket configuration
- New frontend "Phone notifications" card component allows users to toggle the option with clear descriptions
- Message sources functionality (process from self/groups) integrated throughout the stack
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/drizzle/migrations/0013_add_process_from_self_and_groups.sql | Adds columns for processing messages from self and groups (from dependent branch) |
| backend/drizzle/migrations/0014_add_mark_online_on_connect.sql | Adds mark_online_on_connect column with default 0 (false) |
| backend/src/db/schema.ts | Defines processFromSelf, processGroups, and markOnlineOnConnect boolean columns with defaults |
| backend/src/models/whatsapp-connection.model.ts | Adds three boolean fields to WhatsAppConnection interfaces |
| backend/src/repositories/whatsapp-connection.repository.ts | Handles boolean conversion (0/1 ↔ true/false) and optional field updates |
| backend/src/api/validators/whatsapp.validators.ts | Validates optional boolean fields in message filter schema |
| backend/src/api/controllers/whatsapp.controller.ts | Returns new fields in status endpoint, accepts them in update endpoint |
| backend/src/api/controllers/settings.controller.ts | Exports processFromSelf and processGroups (missing markOnlineOnConnect) |
| backend/src/services/whatsapp/whatsapp-client.service.ts | Reads markOnlineOnConnect from DB at init, filters messages based on processFromSelf/processGroups |
| backend/src/services/whatsapp/message-handler.service.ts | Extracts sender JID for group messages to identify actual sender |
| frontend/src/types/whatsapp.types.ts | Adds three boolean fields to WhatsAppConnection type |
| frontend/src/hooks/use-whatsapp.ts | Initializes new boolean fields to false in fallback states |
| frontend/src/pages/whatsapp-connection.tsx | Adds handlers for message sources and phone notifications, preserves all fields when updating |
| frontend/src/components/whatsapp/message-filter-form.tsx | Returns structured payload object instead of separate parameters |
| frontend/src/components/whatsapp/message-sources-card.tsx | New component for toggling processFromSelf and processGroups |
| frontend/src/components/whatsapp/phone-notifications-card.tsx | New component for toggling markOnlineOnConnect |
| backend/tests/unit/repositories/whatsapp-connection.repository.test.ts | Updates test fixtures with new fields (incomplete for markOnlineOnConnect) |
| backend/tests/unit/controllers/whatsapp.controller.test.ts | Updates expectations (incomplete for markOnlineOnConnect) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| processFromSelf: false, | ||
| processGroups: false, | ||
| autoApprovalMode: 'auto_approve', | ||
| exceptionsEnabled: false, | ||
| exceptionContacts: [], |
There was a problem hiding this comment.
The test fixtures are missing the markOnlineOnConnect field. The expected result should include markOnlineOnConnect: false for consistency with the schema definition.
| const isBroadcast = remoteJid === 'status@broadcast'; | ||
|
|
||
| if (fromMe && !processFromSelf) continue; | ||
| if ((isGroup || isBroadcast) && !processGroups) continue; |
There was a problem hiding this comment.
The condition if ((isGroup || isBroadcast) && !processGroups) continue; treats broadcast messages the same as group messages. However, broadcasts (status updates) are different from group messages and should likely be skipped unconditionally. Consider separating these conditions: skip broadcasts always, and skip groups only when !processGroups.
| if ((isGroup || isBroadcast) && !processGroups) continue; | |
| if (isBroadcast) continue; | |
| if (isGroup && !processGroups) continue; |
| processFromSelf: false, | ||
| processGroups: false, | ||
| autoApprovalMode: 'auto_approve', | ||
| exceptionsEnabled: false, | ||
| exceptionContacts: [], |
There was a problem hiding this comment.
The test fixtures are missing the markOnlineOnConnect field. All database row fixtures should include markOnlineOnConnect: 0 and their corresponding expected results should include markOnlineOnConnect: false for consistency with the schema definition.
| processGroups: 0, | ||
| autoApprovalMode: 'auto_approve', | ||
| createdAt: '2023-01-02T00:00:00.000Z', | ||
| updatedAt: '2023-01-02T00:00:00.000Z', |
There was a problem hiding this comment.
The test fixtures are missing the markOnlineOnConnect field. The database row fixture should include markOnlineOnConnect: 0 for consistency with the schema definition.
| updatedAt: '2023-01-02T00:00:00.000Z', | |
| updatedAt: '2023-01-02T00:00:00.000Z', | |
| markOnlineOnConnect: 0, |
| processFromSelf: false, | ||
| processGroups: false, | ||
| autoApprovalMode: 'auto_approve', | ||
| exceptionsEnabled: false, | ||
| exceptionContacts: [], |
There was a problem hiding this comment.
The test fixtures are missing the markOnlineOnConnect field. The expected result should include markOnlineOnConnect: false for consistency with the schema definition.
| filterType: whatsappConnection.filterType, | ||
| filterValue: whatsappConnection.filterValue, | ||
| processFromSelf: whatsappConnection.processFromSelf, | ||
| processGroups: whatsappConnection.processGroups, |
There was a problem hiding this comment.
The markOnlineOnConnect field is missing from the export data. While processFromSelf and processGroups are included in lines 225-226, the markOnlineOnConnect field should also be exported for data consistency.
| processGroups: whatsappConnection.processGroups, | |
| processGroups: whatsappConnection.processGroups, | |
| markOnlineOnConnect: whatsappConnection.markOnlineOnConnect, |
| processFromSelf: 0, | ||
| processGroups: 0, | ||
| autoApprovalMode: 'auto_approve', | ||
| exceptionsEnabled: 0, | ||
| exceptionContacts: [], |
There was a problem hiding this comment.
The test fixtures are missing the markOnlineOnConnect field. All database row fixtures should include markOnlineOnConnect: 0 and their corresponding expected results should include markOnlineOnConnect: false for consistency with the schema definition.
| processFromSelf: false, | ||
| processGroups: false, | ||
| autoApprovalMode: 'auto_approve', | ||
| exceptionsEnabled: false, | ||
| exceptionContacts: [], |
There was a problem hiding this comment.
The test fixtures are missing the markOnlineOnConnect field. All database row fixtures should include markOnlineOnConnect: 0 and their corresponding expected results should include markOnlineOnConnect: false for consistency with the schema definition.
| processFromSelf: false, | ||
| processGroups: false, | ||
| autoApprovalMode: 'auto_approve', | ||
| exceptionsEnabled: false, | ||
| exceptionContacts: [], |
There was a problem hiding this comment.
The test fixtures are missing the markOnlineOnConnect field. All database row fixtures should include markOnlineOnConnect: 0 and their corresponding expected results should include markOnlineOnConnect: false for consistency with the schema definition.
| processFromSelf: false, | ||
| processGroups: false, | ||
| autoApprovalMode: 'auto_approve', | ||
| exceptionsEnabled: false, | ||
| exceptionContacts: [], |
There was a problem hiding this comment.
The test fixtures are missing the markOnlineOnConnect field. The expected result should include markOnlineOnConnect: false for consistency with the schema definition.
techieanant
left a comment
There was a problem hiding this comment.
Please see review comments.
Description
Makes the Baileys
markOnlineOnConnectoption configurable so users can choose whether the linked WhatsApp session appears "online" when WAMR is connected. Default is off so the phone keeps receiving notifications and unread badges while WAMR still receives and processes messages.Type of Change
Related Issues
Closes #
Relates to #
Changes Made
mark_online_on_connecttowhatsapp_connections(migration 0014), defaultfalse.markOnlineOnConnect; status endpoint includes it.makeWASocket()(applies on next connect/reconnect).useWhatsApphook updated formarkOnlineOnConnect; filter/message-source saves pass it through so it is not overwritten.Screenshots
Click to view screenshots
Testing
How Has This Been Tested?
Test Configuration
Test Coverage
Checklist
Code Quality
npm run lintand resolved all issuesnpm run formatto format my codeTesting
Documentation
Dependencies
npm auditto check for security vulnerabilitiesCommits
Breaking Changes
None. New column has a default; existing rows get
mark_online_on_connect = 0(false).Additional Notes
feature/process-from-self-and-groups. DefaultmarkOnlineOnConnect: falsematches the previous hardcoded behaviour and keeps phone notifications working.For Reviewers
Areas to Focus On
Questions for Reviewers
Thank you for contributing to WAMR!