feat(engine): Baileys reply/forward/react/delete + persisted store (slice 2b)#308
Merged
Conversation
…e2e/dev boot crash)
This was referenced Jun 18, 2026
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 2b of the Baileys engine: un-gates reply / forward / react / delete, backed by a DB-persisted message store (Baileys 6.7.23 ships none) that survives restarts.
Stacked on #307 (base branch
feat/baileys-media-sends, which is itself stacked on #299). This PR's diff is slice-2b only; once #307 → #299 merge, I'll retarget the base tomain.What's added
replyToMessage→sock.sendMessage(chatId, { text }, { quoted })·forwardMessage→{ forward }·reactToMessage→{ react: { text, key } }·deleteMessage(revoke for everyone) →{ delete: key }. A store miss throws a clearMessage <id> not found;delete-for-me(forEveryone=false) returns HTTP 501.baileys_stored_messages('data'connection, CASCADE-deleted with its session): maps(sessionId, waMessageId)→ the serializedWAMessage(via Baileys' ownBufferJSON). Populated fire-and-forget on every inbound + outbound message; cleared on logout; bounded per-session byBAILEYS_MESSAGE_STORE_LIMIT(default 5000) via a(createdAt, id)cutoff range-delete.getFeatures()now advertisesmessage-replies,message-forwarding,message-reactions,message-deletion.Architecture
EngineFactoryand threaded through the plugin constructor into the adapter config — the neutral per-callcreateEnginecontract (feat(engine): opaque per-engine config (engine-agnostic EngineFactory) #296) is untouched, and the Baileys proto/key never leaks into the neutral pipeline (messagestable, webhooks, dashboard). The adapter depends on a narrowBaileysMessageStoreinterface, not the Nest service.BufferJSON/WAMessagefrom the installed lib + TypeORM).This engine now persists recent message protos to the data DB (so reply/forward/react/delete survive restarts) — more data-at-rest than the whatsapp-web.js engine, which resolves only from a live in-memory window. It is bounded per-session by
BAILEYS_MESSAGE_STORE_LIMIT, CASCADE-deleted with the session, and cleared on logout. Operators with retention/GDPR concerns can tune the cap.Out of scope (still 501)
getMessageReactions(reading reactions — needs reaction-event aggregation),deleteMessagefor-me, and everything store-backed-reads (contacts/groups/chats/history) → slice 3.Testing
sendMessageshape, store-miss throw, delete-for-me 501, populate-on-upsert/send, clear-on-logout); migration up/down in-memory; the e2e boot gate (feature list synced).migrations/*{.ts,.js}glob (TypeORM loaded a test file as a migration, crashing e2e/dev boot) — moved to a__tests__/subdir.