From f09e0f85ccf93e47a7ca81a35df7928ed24623f4 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Thu, 13 Jan 2022 16:26:56 +0530 Subject: [PATCH] feat: add getContentType --- src/Utils/messages.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Utils/messages.ts b/src/Utils/messages.ts index cbb6dab..31655f0 100644 --- a/src/Utils/messages.ts +++ b/src/Utils/messages.ts @@ -426,6 +426,14 @@ export const generateWAMessage = async( ) } +/** Get the key to access the true type of content */ +export const getContentType = (content: WAProto.IMessage | undefined) => { + if(content) { + const keys = Object.keys(content) + const key = keys.find(k => (k === 'conversation' || k.endsWith('Message')) && k !== 'senderKeyDistributionMessage') + return key as keyof typeof content + } +} /** * Extract the true message content from a message * Eg. extracts the inner message from a disappearing message/view once message