feat(engine): Baileys contacts/chats + read-receipts (slice 3b, final)#310
Merged
Conversation
…ak; sound catch errors
…ner-leak uniformity)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Slice 3b — the final Baileys slice: un-gates
getContacts/getContactById/getChats/resolveContactPhone/sendSeen/deleteChat, backed by a per-session in-memory store fed from Baileys events. After this, the Baileys engine implements every neutralIWhatsAppEnginecapability it can meaningfully support.Stacked on #309 (base
feat/baileys-groups, itself stacked on #308 → #307 → #299). Diff is slice-3b only; the base retargets tomainas the stack merges down.What's added
BaileysSessionStore(new, in-memory, no DB/DI) — per-session maps for contacts, chats, last-message-per-chat, and lid→phone, fed fire-and-forget fromcontacts.upsert/update,chats.upsert/update,messaging-history.set, andmessages.upsert. Rebuilt on each connect's history sync; type-only Baileys imports keep it engine-neutral and unit-testable without a socket.getContacts/getContactById/getChats→ mapped from the store to neutralContact/ChatSummary.resolveContactPhone→ best-effort via the id user-part /lidPnMappings/ a contact'sphoneNumber, elsenull.sendSeen(chatId)→readMessages([lastKey])(falsewhen no last message is known).deleteChat(chatId)→chatModify({ delete: true, lastMessages: [...] }, chatId)(falsewhen unknown).getFeatures()now advertisesread-receipts.Why in-memory (not persisted like 2b)
Baileys re-syncs the full contact + chat list via
messaging-history.seton every connect, so this is current-state data, not a durable append-log — an in-memory store rebuilt on connect is the right fit and avoids new tables/migrations/repos. It survives transient reconnects (instance state) and repopulates after a process restart on the next connect. No new data-at-rest.Out of scope — gated (501)
getChatHistory— Baileys has no on-demand history API (unlike wwjs's livefetchMessages); serving from the bounded message store would mislead.getMessageReactions, labels/channels/status/catalog — parity with the whatsapp-web.js engine (which also stubs them); likely permanent.These are now the only gated methods — the Baileys engine is feature-complete vs the neutral interface.
Best-effort notes
Contact.isMyContact = true/isBlocked = false(blocklist not tracked);getChatslastMessage/timestamppopulate from live messages (fallbackconversationTimestamp). Documented.Testing
BaileysSessionStore(full+partial merge, newest-message-wins, neutral mapping, lid resolution); adapter (events populate → reads return mapped neutral;messaging-history.setincl. lid;sendSeen/deleteChatcall args +false-when-unknown;getChatHistorystill 501;ensureReadyguards); e2e feature list synced to 11. Fixed a FakeSock listener leak (MaxListenersExceededWarning) by resetting the emitter per describe.