From 9e096c731c3974004555131e16f3bd686ba4d1e5 Mon Sep 17 00:00:00 2001 From: fadiinho Date: Mon, 25 Jul 2022 04:23:10 -0300 Subject: [PATCH] feat: add reaction update to the store --- src/Store/make-in-memory-store.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Store/make-in-memory-store.ts b/src/Store/make-in-memory-store.ts index 4cf4aa8..8d68cc1 100644 --- a/src/Store/make-in-memory-store.ts +++ b/src/Store/make-in-memory-store.ts @@ -6,7 +6,7 @@ import { DEFAULT_CONNECTION_CONFIG } from '../Defaults' import type makeLegacySocket from '../LegacySocket' import type makeMDSocket from '../Socket' import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types' -import { toNumber, updateMessageWithReceipt } from '../Utils' +import { toNumber, updateMessageWithReaction, updateMessageWithReceipt } from '../Utils' import { jidNormalizedUser } from '../WABinary' import makeOrderedDictionary from './make-ordered-dictionary' @@ -230,6 +230,16 @@ export default ( } } }) + + ev.on('messages.reaction', (reactions) => { + for(const { key, reaction } of reactions) { + const obj = messages[key.remoteJid!] + const msg = obj?.get(key.id!) + if(msg) { + updateMessageWithReaction(msg, reaction) + } + } + }) } const toJSON = () => ({ @@ -379,4 +389,4 @@ export default ( } } } -} \ No newline at end of file +}