Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(baileys): add BAILEYS_MARK_ONLINE_ON_CONNECT to gate on-connect presence (#1057)
Yudhi Armyndharis0120d093d937
diff --git a/.env.example b/.env.exampleindex 9d47ac86b..869cc176c 100644--- a/.env.example+++ b/.env.example@@ -162,6 +162,12 @@ BAILEYS_AUTH_DIR=./data/baileys# Pull the FULL message-history archive on connect (large). Off by default: the engine still enables the# initial sync (contacts, chats, recent messages, lid mappings) without downloading the entire history.BAILEYS_SYNC_FULL_HISTORY=false+# Announce the linked device as online when the socket connects. Baileys' default is true, which+# suppresses WhatsApp push notifications on the paired phone while the gateway is connected —+# a 24/7 gateway then silences the phone permanently (#871). Set to false to keep phone+# notifications working. Only gates the on-connect presence: the typing / chat-state send API+# still announces per-chat presence for that call.+BAILEYS_MARK_ONLINE_ON_CONNECT=true# Device name shown in WhatsApp Settings → Linked Devices for NEW pairings (existing sessions keep# the name they were paired with until re-linked). Default: OpenWA.# BAILEYS_BROWSER_NAME=diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 44758bf4b..5cdd1899c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Added++- `BAILEYS_MARK_ONLINE_ON_CONNECT=false` keeps phone push notifications alive while a Baileys gateway is connected (default `true`, prior behavior). (#871)+### Fixed- **A key pasted with a stray space now authenticates on the WebSocket, not just over REST.**diff --git a/src/engine/adapters/baileys-lifecycle.ts b/src/engine/adapters/baileys-lifecycle.tsindex baffdccf8..484f24c92 100644--- a/src/engine/adapters/baileys-lifecycle.ts+++ b/src/engine/adapters/baileys-lifecycle.ts@@ -243,6 +243,13 @@ export class BaileysLifecycle {// RECENT window + the full contact/app-state snapshot, not the entire message history.shouldSyncHistoryMessage: () => true,syncFullHistory: process.env.BAILEYS_SYNC_FULL_HISTORY === 'true',+ // Baileys defaults markOnlineOnConnect to true: every (re)connect broadcasts `available`,+ // and WhatsApp suppresses the paired phone's push notifications while any linked device is+ // online — a 24/7 gateway then permanently silences the phone (#871). Set+ // BAILEYS_MARK_ONLINE_ON_CONNECT=false to stay invisible; the default preserves prior+ // behavior. Note this only gates the on-connect presence: the typing / chat-state API still+ // sends per-chat presence for that call regardless.+ markOnlineOnConnect: process.env.BAILEYS_MARK_ONLINE_ON_CONNECT !== 'false',// Baileys defaults this to `async () => undefined` (Defaults/index.js). Without a real// implementation, WhatsApp's message-retry protocol — triggered whenever a recipient's client// fails to decrypt on the first attempt — has nothing to resend, so the recipient is stuck on