Skip to content

Commit

Permalink
fix: In memory store: normalize user when asserting message list to u…
Browse files Browse the repository at this point in the history
…pdate messages (#49)

* normalize user when asserting message list to update messages

* in memory

* update verifies status

* code style improved
  • Loading branch information
dudagervasio committed May 18, 2023
1 parent e35f486 commit 7b4abcd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Store/make-in-memory-store.ts
Expand Up @@ -167,7 +167,16 @@ export default (
})
ev.on('messages.update', updates => {
for(const { update, key } of updates) {
const list = assertMessageList(key.remoteJid!)
const list = assertMessageList(jidNormalizedUser(key.remoteJid!))
if(update?.status) {
const listStatus = list.get(key.id!)?.status
if(listStatus && update?.status <= listStatus) {
logger.debug({ update, storedStatus: listStatus }, 'status stored newer then update')
delete update.status
logger.debug({ update }, 'new update object')
}
}

const result = list.updateAssign(key.id!, update)
if(!result) {
logger.debug({ update }, 'got update for non-existent message')
Expand Down

0 comments on commit 7b4abcd

Please sign in to comment.