feat: add getContentType

This commit is contained in:
Adhiraj Singh
2022-01-13 16:26:56 +05:30
parent ede40b16f1
commit f09e0f85cc

View File

@@ -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