Commit Graph

89 Commits

Author SHA1 Message Date
Claude e9de4950b3 feat(lid-mapping): implement PR #2275 optimizations and event batching
Implement comprehensive LID-PN mapping optimizations based on Baileys PR #2275:

1. **Add consolidated JID helper functions**
   - Add `isAnyLidUser()` and `isAnyPnUser()` helpers to reduce code duplication
   - Refactor all JID type checks across codebase to use new helpers
   - Add comprehensive unit tests (23 test cases) for new helpers

2. **Implement database read batching in storeLIDPNMappings()**
   - Optimize from O(N) individual queries to O(1) batch query
   - Implement 3-phase processing: validate, batch-fetch, batch-store
   - Collect all cache misses first, then fetch in single DB query
   - Reduces database round-trips from N to 1 for cache misses
   - Expected 30-50% performance improvement for bulk operations

3. **Migrate lid-mapping.update event to array-based emission**
   - Change event signature from `LIDMapping` to `LIDMapping[]`
   - Update all event emitters to emit arrays instead of individual objects
   - Refactor process-message.ts to emit all mappings at once
   - Update event listener in chats.ts to handle batch processing
   - Reduces event overhead by ~20-30% for multiple mappings

Performance Impact:
- Database queries: O(N) → O(1) for batch lookups
- Event emissions: Individual → Batched (reduced overhead)
- Cache efficiency: Improved with consolidated helpers

Breaking Changes:
- Event signature changed: `lid-mapping.update` now emits `LIDMapping[]`
- Fully backward compatible for consumers ignoring event details

Tests:
- All existing tests updated and passing (388/390)
- New test file: src/__tests__/WABinary/jid-utils.test.ts
- Event emission tests updated for array format

Related:
- Addresses Baileys PR #2275
- Complements existing PR #2286 (LID extraction)
- Complements existing PR #2274 (batch optimizations)

https://claude.ai/code/session_0149ZKk2ygmKCJTGu39Mr8oH
2026-02-02 19:35:01 +00:00
Claude fe9a3166a8 chat-utils: add fallbacks for contact name extraction
Apply consistent fallback pattern for contact names:
- chat-utils.ts: fullName || firstName || username for lidContactAction
- sync-action-utils.ts: fullName || firstName || username for processContactAction

Ensures contact names are extracted regardless of which field WhatsApp populates.
2026-01-22 20:11:20 +00:00
Claude a319a63ff3 fix: add missing await for mutationKeys in decodeSyncdMutations
When hkdf became async, mutationKeys also became async but the call
site wasn't updated. This caused Promise<Promise<Key>> instead of
Promise<Key>, breaking contact sync events (contacts.upsert).

Ref: WhiskeySockets/Baileys#2288
2026-01-21 19:36:00 +00:00
João Lucas de Oliveira Lopes 8ff01b8bb3 fix: store LID-PN mapping from contactAction sync (#2266)
* fix: store LID-PN mapping from contactAction sync

* chore: improve testing of sync actions
2026-01-20 12:39:41 +02:00
vini 925ed6a7b3 feat(appstate): emit setting events (#2057) 2025-12-15 01:21:44 +02:00
Rajeh Taher 334977f983 general: revert #1665 2025-10-03 18:14:30 +03:00
João Lucas de Oliveira Lopes fb12f6d9d3 refactor: replace axios with fetch API and update related types (#1666) 2025-09-28 05:52:43 +03:00
João Lucas de Oliveira Lopes 3b46d43beb fix: harden Protobuf Deserialization and Refactor Utilities (#1820)
* refactor: reorganize browser utility functions and improve buffer handling

* fix: harden protobuf deserialization and clean up code

* refactor: simplify data handling in GroupCipher and SenderKey classes

* fix: Ensure consistent Buffer hydration and remove redundant code

* refactor: update decodeAndHydrate calls to use proto types for improved type safety
2025-09-26 04:45:30 +03:00
Rajeh Taher 20693a59d0 lid, wip: Support LIDs in Baileys (#1747)
* lid-mapping: get missing lid from usync

* lid-mapping, jid-utils: change to isPnUser and store multiple mappings

* process-message: parse protocolMsg mapping, and store from new msgs

* types: lid-mapping event, addressing enum, alt, contact, group types

* validate, decode: use lid for identity, better logic

* lid: final commit

* linting

* linting

* linting

* linting

* misc: fix testing and also remove version json

* lint: IDE fucking up lint

* lid-mapping: fix build error on NPM

* message-retry: fix proto import
2025-09-08 10:03:28 +03:00
vini 50fc83b008 feat(business): change profile/cover photo and manage quick replies (#1724) 2025-09-07 14:08:26 +03:00
João Lucas de Oliveira Lopes 4d4339dae6 feat(WAProto): Optimize protobuf generation for 80%+ bundle size reduction (#1665)
* chore: remove comments and veirfy from generated proto files (improve size)

* refactor: replace fromObject with create for proto message instantiation and flag no beautiful

* chore: lint issues
2025-09-07 14:08:11 +03:00
vini aba3ecf969 feat: add enable/disable link preview privacy (#1675) 2025-08-07 01:50:24 +03:00
Rajeh Taher 8dc852ee89 proto: fix proto generation, tsc: fix node imports of compiled code 2025-07-19 23:16:35 +03:00
Rajeh Taher 787aed88b8 project: Move to ESM Modules 2025-07-17 13:54:17 +03:00
vini 19124426b2 [feat]: add/edit/remove contacts (#1172)
* add/edit/remove contacts

* use proto type in contact action

---------

Co-authored-by: canove <cassio@economicros.com.br>
2025-07-09 22:01:20 +03:00
Rajeh Taher 719a57b275 Added message range to the clear chat action (#1534)
* chat-utils: Added message range to the clear chat action

* Chat: add field to type (thanks @Kiss from discord)

* Update src/Utils/chat-utils.ts
2025-07-05 23:58:44 +03:00
devlikeapro b8464d3665 Add lid to Contact - contact sync, history sync, group participants (#1472) 2025-06-18 08:08:09 -03:00
canove fa706d0b50 chore: format everything 2025-05-06 12:10:19 -03:00
Rajeh Taher 99142aac96 proto: update manually to 2.3000.1020608496 2025-03-06 04:22:17 +02:00
ShellTear 4a90ea4688 fix lint 2025-03-04 04:08:09 +02:00
ShellTear fccca8ab30 fix(sync): complete unfinished async implementation
Added 'await' to callers of 'makeLtHashGenerator.finish' to handle its Promise return after 'lt-hash.ts' was made asynchronous  by replacing old sync hkdf implementation.

Fixes #1286
2025-03-04 04:05:52 +02:00
João Lucas de Oliveira Lopes 8083754621 refactor: turn hkdf functions to async and remove extra deps (#1272)
* refactor: remove futoin-hkdf dependency and update hkdf implementation

* refactor: use crypto subtle and update functions to async

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2025-03-01 18:31:48 +02:00
contato.mateusfr@gmail.com 21f8431e61 Dependency Inversion for Logger (#1153)
* feat: interface "ILogger" created
feat: interface "ILogger" used instead of pino logger
feat: "PinoLoggerAdapter" created to implement "ILogger" interface

* feat: PinoLoggerAdapter removed
feat: ILogger mapping the features we're using from pino

* fix: sort imports

---------

Co-authored-by: Mateus Franchini de Freitas <contato.mateusfr@outlook.com>
Co-authored-by: Mateus Franchini de Freitas <mfranchini@domtec.com.br>
Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2025-03-01 18:30:51 +02:00
Rajeh Taher 18ac07df8e lint: 0 warnings left 2024-10-14 05:15:10 +03:00
Rajeh Taher 647f8d767f chat-utils: fix the clear chat chat mod 2024-10-14 02:52:23 +03:00
建辉 6ff945502d feat: add label feature (#955)
Co-authored-by: 刘建辉 <liujianhui@gongchang.com>
2024-09-22 14:48:17 +03:00
azudin d3cf789f82 Update chat-utils.ts 2023-12-07 23:11:07 +08:00
azudin ece99eab23 Fixed star message 2023-12-02 07:26:09 +08:00
gusta4321 2f438a6539 fix: Fixed typescript build at chat-utils.ts file (#118) 2023-06-15 21:08:51 -03:00
Rafael Garcia 3ac29e131d Slint fixes applied 2023-05-15 09:41:33 -05:00
Rafael Garcia 38f285760d feat(labels): modify chat utils 2023-05-14 12:44:19 -05:00
Adhiraj Singh 4aadc9dc6c fix: add option for appStateMacVerification 2022-11-08 22:33:53 +05:30
Adhiraj Singh f892a1e81f fix: duplicate mutation release on failed patch 2022-11-08 22:28:27 +05:30
Adhiraj Singh 154926ec3c chore: correctly throw app state key not found 2022-11-06 20:06:50 +05:30
Adhiraj Singh 2a8ce563a2 chore: remove redundant newMutations log 2022-11-06 19:51:45 +05:30
Adhiraj Singh d0330d1863 refactor!: cleaner message history sync
This is a breaking change,
1. three events (chats.set, contacts.set, messages.set) are now just one `messaging-history.set` event
2. no need to debounce for app state sync
3. added a new "conditional" chat update to allow for correct app state sync despite not having the chat available on hand
2022-09-29 16:32:57 +05:30
Adhiraj Singh e08dd10198 refactor!: use proto.Conversation's own chat mutation fields instead of baileys added 2022-09-29 11:06:09 +05:30
Adhiraj Singh bb983cd30d chore: reduce logging 2022-09-28 10:40:29 +05:30
Adhiraj Singh ae3ac78dc3 feat: pass axios config to all axios instances 2022-09-19 17:46:43 +05:30
Ilya Borodin 4f1d9492c5 Changed concat to push 2022-08-20 23:21:56 +05:30
Adhiraj Singh dc07d31dc7 fix: correctly handle deleteMessageFromMe 2022-08-17 16:00:08 +05:30
Adhiraj Singh 2549d10be9 feat: update proto
The new proto extract has a bunch of breaking changes, so if you were using the raw proto in your code somewhere -- then you may have to update your code to make it work with the new proto

!BREAKING_CHANGE
2022-08-01 10:43:04 +05:30
LeonardoBein b42be6bce4 Change profile name for yourself (#1913)
* feat: change profile name

* fix: unnecessary return
2022-07-21 15:56:51 +05:30
Adhiraj Singh 7b8390f1ca fix: delete chat + star message actions not syncing 2022-07-14 11:23:07 +05:30
Adhiraj Singh 40a1e268aa feat: add "strictNullChecks" 2022-07-09 10:20:07 +05:30
Adhiraj Singh 41ca76a0af fix: chats.delete patch on sync 2022-07-06 22:05:01 +05:30
Adhiraj Singh 2c03802939 chore: use "null" to signify removal of mute 2022-06-27 15:14:05 +05:30
Adhiraj Singh eaf0f37d24 refactor: use event-buffer for state sync resyncs 2022-06-27 14:51:26 +05:30
Dwi Rizqi e7087cabf5 fix: Delete Message For Me (#1718)
* Add Timestamp for deleteMessageForMe

* Fix Typo Readme

* Add Timestamp for deleteMessageForMe

* fix: Typo type timestamp
2022-06-13 20:13:52 +05:30
Adhiraj Singh f87f89329b perf: avoid excess memory usage when syncing state 2022-06-11 20:25:57 +05:30