* 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:
@@ -39,6 +39,39 @@ export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL
|
||||
/** Set of message types that are supported by the library */
|
||||
export type MessageType = keyof proto.Message
|
||||
|
||||
export type MessageWithContextInfo =
|
||||
| 'imageMessage'
|
||||
| 'contactMessage'
|
||||
| 'locationMessage'
|
||||
| 'extendedTextMessage'
|
||||
| 'documentMessage'
|
||||
| 'audioMessage'
|
||||
| 'videoMessage'
|
||||
| 'call'
|
||||
| 'contactsArrayMessage'
|
||||
| 'liveLocationMessage'
|
||||
| 'templateMessage'
|
||||
| 'stickerMessage'
|
||||
| 'groupInviteMessage'
|
||||
| 'templateButtonReplyMessage'
|
||||
| 'productMessage'
|
||||
| 'listMessage'
|
||||
| 'orderMessage'
|
||||
| 'listResponseMessage'
|
||||
| 'buttonsMessage'
|
||||
| 'buttonsResponseMessage'
|
||||
| 'interactiveMessage'
|
||||
| 'interactiveResponseMessage'
|
||||
| 'pollCreationMessage'
|
||||
| 'requestPhoneNumberMessage'
|
||||
| 'messageHistoryBundle'
|
||||
| 'eventMessage'
|
||||
| 'newsletterAdminInviteMessage'
|
||||
| 'albumMessage'
|
||||
| 'stickerPackMessage'
|
||||
| 'pollResultSnapshotMessage'
|
||||
| 'messageHistoryNotice'
|
||||
|
||||
export type DownloadableMessage = { mediaKey?: Uint8Array | null; directPath?: string | null; url?: string | null }
|
||||
|
||||
export type MessageReceiptType =
|
||||
|
||||
+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