* fix: correcting if logic for contextInfo * fix: typing of the logic [BUG] Can't mention number/someone Fixes #1628 * lint: whitespace issues
This commit is contained in:
+11
-5
@@ -14,6 +14,7 @@ import type {
|
||||
MessageGenerationOptions,
|
||||
MessageGenerationOptionsFromContent,
|
||||
MessageUserReceipt,
|
||||
MessageWithContextInfo,
|
||||
WAMediaUpload,
|
||||
WAMessage,
|
||||
WAMessageContent,
|
||||
@@ -541,11 +542,14 @@ export const generateWAMessageContent = async (
|
||||
}
|
||||
|
||||
if ('mentions' in message && message.mentions?.length) {
|
||||
const messageType = Object.keys(m)[0]! as Exclude<keyof proto.IMessage, 'conversation'>
|
||||
const messageType = Object.keys(m)[0]! as Extract<keyof proto.IMessage, MessageWithContextInfo>
|
||||
const key = m[messageType]
|
||||
if ('contextInfo' in key!) {
|
||||
key.contextInfo = key.contextInfo || {}
|
||||
if ('contextInfo' in key! && !!key.contextInfo) {
|
||||
key.contextInfo.mentionedJid = message.mentions
|
||||
} else if (key!) {
|
||||
key.contextInfo = {
|
||||
mentionedJid: message.mentions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,10 +565,12 @@ export const generateWAMessageContent = async (
|
||||
}
|
||||
|
||||
if ('contextInfo' in message && !!message.contextInfo) {
|
||||
const messageType = Object.keys(m)[0]! as Exclude<keyof proto.IMessage, 'conversation'>
|
||||
const messageType = Object.keys(m)[0]! as Extract<keyof proto.IMessage, MessageWithContextInfo>
|
||||
const key = m[messageType]
|
||||
if ('contextInfo' in key!) {
|
||||
if ('contextInfo' in key! && !!key.contextInfo) {
|
||||
key.contextInfo = { ...key.contextInfo, ...message.contextInfo }
|
||||
} else if (key!) {
|
||||
key.contextInfo = message.contextInfo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user