fix: correcting if logic for contextInfo (#1628) (#1629)

* 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:
Nurutomo
2025-07-27 04:58:14 +07:00
committed by GitHub
parent b7876da2e5
commit cdd2f0d53f
2 changed files with 44 additions and 5 deletions
+11 -5
View File
@@ -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
}
}