feat: add message events for reactions

This commit is contained in:
Adhiraj Singh
2022-03-23 00:40:46 +05:30
parent 3a52f06c0f
commit 9fee7faaf6
3 changed files with 27 additions and 1 deletions

View File

@@ -143,7 +143,21 @@ const makeMessagesSocket = (config: LegacySocketConfig) => {
}
}
const protocolMessage = normalizeMessageContent(message.message)?.protocolMessage
const normalizedContent = normalizeMessageContent(message.message)
const protocolMessage = normalizedContent?.protocolMessage
if(normalizedContent.reactionMessage) {
const reaction: proto.IReaction = {
...normalizedContent.reactionMessage,
key: message.key,
}
const operation = normalizedContent.reactionMessage?.text ? 'add' : 'remove'
ev.emit(
'messages.reaction',
{ reaction, key: normalizedContent.reactionMessage!.key!, operation }
)
}
// if it's a message to delete another message
if(protocolMessage) {
switch (protocolMessage.type) {