Skip to content

Feature/mark online configurable#43

Open
winterborn wants to merge 2 commits intotechieanant:mainfrom
winterborn:feature/mark-online-configurable
Open

Feature/mark online configurable#43
winterborn wants to merge 2 commits intotechieanant:mainfrom
winterborn:feature/mark-online-configurable

Conversation

@winterborn
Copy link

Description

Makes the Baileys markOnlineOnConnect option 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition/improvement
  • Dependency update
  • Other (please describe):

Related Issues

Closes #
Relates to #

Changes Made

  • Backend: Added mark_online_on_connect to whatsapp_connections (migration 0014), default false.
  • Backend: Extended filter API (validator, controller, repository) to accept and return markOnlineOnConnect; status endpoint includes it.
  • Backend: WhatsApp client reads the option at init from the DB and passes it to makeWASocket() (applies on next connect/reconnect).
  • Frontend: New "Phone notifications" card on WhatsApp Connection page with one toggle: "Mark as online when connected", plus short description and note that changes apply on next connect.
  • Frontend: Types and useWhatsApp hook updated for markOnlineOnConnect; filter/message-source saves pass it through so it is not overwritten.

Screenshots

Click to view screenshots

Testing

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • E2E tests
  • Manual testing

Test Configuration

  • Node.js version: 20+
  • npm version: 10+
  • OS: Mac / Windows

Test Coverage

  • No new tests added; existing flows unchanged.

Checklist

Code Quality

  • My code follows the project's coding conventions
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run npm run lint and resolved all issues
  • I have run npm run format to format my code
  • My changes generate no new warnings

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Documentation

  • I have updated the documentation accordingly
  • I have updated the README.md if needed
  • I have added/updated JSDoc comments for new functions
  • I have updated the API documentation if applicable

Dependencies

  • I have checked for and resolved any dependency conflicts
  • I have run npm audit to check for security vulnerabilities
  • I have updated the changelog if this is a significant change

Commits

  • My commits follow the conventional commits specification
  • I have squashed any unnecessary commits
  • My commit messages are clear and descriptive

Breaking Changes

None. New column has a default; existing rows get mark_online_on_connect = 0 (false).

Additional Notes

  • This PR is based on feature/process-from-self-and-groups. Default markOnlineOnConnect: false matches the previous hardcoded behaviour and keeps phone notifications working.

For Reviewers

Areas to Focus On

  • Migration 0014 and schema default.
  • That the client only reads the option at init (reconnect required for changes).
  • Wording and placement of the Phone notifications card.

Questions for Reviewers

  • None.

Thank you for contributing to WAMR!

winterborn and others added 2 commits February 5, 2026 00:09
- 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]>
@winterborn winterborn force-pushed the feature/mark-online-configurable branch from 3c164f3 to 94b742f Compare February 6, 2026 15:49
@winterborn winterborn marked this pull request as ready for review February 6, 2026 15:51
@techieanant techieanant requested a review from Copilot February 14, 2026 00:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_connect column with default false
  • 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.

Comment on lines +495 to 499
processFromSelf: false,
processGroups: false,
autoApprovalMode: 'auto_approve',
exceptionsEnabled: false,
exceptionContacts: [],
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test fixtures are missing the markOnlineOnConnect field. The expected result should include markOnlineOnConnect: false for consistency with the schema definition.

Copilot uses AI. Check for mistakes.
const isBroadcast = remoteJid === 'status@broadcast';

if (fromMe && !processFromSelf) continue;
if ((isGroup || isBroadcast) && !processGroups) continue;
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if ((isGroup || isBroadcast) && !processGroups) continue;
if (isBroadcast) continue;
if (isGroup && !processGroups) continue;

Copilot uses AI. Check for mistakes.
Comment on lines +153 to 157
processFromSelf: false,
processGroups: false,
autoApprovalMode: 'auto_approve',
exceptionsEnabled: false,
exceptionContacts: [],
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
processGroups: 0,
autoApprovalMode: 'auto_approve',
createdAt: '2023-01-02T00:00:00.000Z',
updatedAt: '2023-01-02T00:00:00.000Z',
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test fixtures are missing the markOnlineOnConnect field. The database row fixture should include markOnlineOnConnect: 0 for consistency with the schema definition.

Suggested change
updatedAt: '2023-01-02T00:00:00.000Z',
updatedAt: '2023-01-02T00:00:00.000Z',
markOnlineOnConnect: 0,

Copilot uses AI. Check for mistakes.
Comment on lines +290 to 294
processFromSelf: false,
processGroups: false,
autoApprovalMode: 'auto_approve',
exceptionsEnabled: false,
exceptionContacts: [],
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test fixtures are missing the markOnlineOnConnect field. The expected result should include markOnlineOnConnect: false for consistency with the schema definition.

Copilot uses AI. Check for mistakes.
filterType: whatsappConnection.filterType,
filterValue: whatsappConnection.filterValue,
processFromSelf: whatsappConnection.processFromSelf,
processGroups: whatsappConnection.processGroups,
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
processGroups: whatsappConnection.processGroups,
processGroups: whatsappConnection.processGroups,
markOnlineOnConnect: whatsappConnection.markOnlineOnConnect,

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +68
processFromSelf: 0,
processGroups: 0,
autoApprovalMode: 'auto_approve',
exceptionsEnabled: 0,
exceptionContacts: [],
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +91 to 95
processFromSelf: false,
processGroups: false,
autoApprovalMode: 'auto_approve',
exceptionsEnabled: false,
exceptionContacts: [],
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +241 to 245
processFromSelf: false,
processGroups: false,
autoApprovalMode: 'auto_approve',
exceptionsEnabled: false,
exceptionContacts: [],
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +341 to 345
processFromSelf: false,
processGroups: false,
autoApprovalMode: 'auto_approve',
exceptionsEnabled: false,
exceptionContacts: [],
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test fixtures are missing the markOnlineOnConnect field. The expected result should include markOnlineOnConnect: false for consistency with the schema definition.

Copilot uses AI. Check for mistakes.
Copy link
Owner

@techieanant techieanant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see review comments.

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.

3 participants