mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: correctly generate quoted msgs
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
|||||||
WAProto,
|
WAProto,
|
||||||
WATextMessage,
|
WATextMessage,
|
||||||
} from '../Types'
|
} from '../Types'
|
||||||
|
import { jidNormalizedUser } from '../WABinary'
|
||||||
import { generateMessageID, unixTimestampSeconds } from './generics'
|
import { generateMessageID, unixTimestampSeconds } from './generics'
|
||||||
import { downloadContentFromMessage, encryptedStream, generateThumbnail, getAudioDuration, MediaDownloadOptions } from './messages-media'
|
import { downloadContentFromMessage, encryptedStream, generateThumbnail, getAudioDuration, MediaDownloadOptions } from './messages-media'
|
||||||
|
|
||||||
@@ -396,16 +397,28 @@ export const generateWAMessageFromContent = (
|
|||||||
if(quoted) {
|
if(quoted) {
|
||||||
const participant = quoted.key.fromMe ? userJid : (quoted.participant || quoted.key.participant || quoted.key.remoteJid)
|
const participant = quoted.key.fromMe ? userJid : (quoted.participant || quoted.key.participant || quoted.key.remoteJid)
|
||||||
|
|
||||||
message[key].contextInfo = message[key].contextInfo || { }
|
let quotedMsg = normalizeMessageContent(quoted.message)
|
||||||
message[key].contextInfo.participant = participant
|
const msgType = getContentType(quotedMsg)
|
||||||
message[key].contextInfo.stanzaId = quoted.key.id
|
// strip any redundant properties
|
||||||
message[key].contextInfo.quotedMessage = quoted.message
|
quotedMsg = proto.Message.fromObject({ [msgType]: quotedMsg[msgType] })
|
||||||
|
|
||||||
|
const quotedContent = quotedMsg[msgType]
|
||||||
|
if(typeof quotedContent === 'object' && quotedContent && 'contextInfo' in quotedContent) {
|
||||||
|
delete quotedContent.contextInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
const contextInfo: proto.IContextInfo = message[key].contextInfo || { }
|
||||||
|
contextInfo.participant = jidNormalizedUser(participant)
|
||||||
|
contextInfo.stanzaId = quoted.key.id
|
||||||
|
contextInfo.quotedMessage = quotedMsg
|
||||||
|
|
||||||
// if a participant is quoted, then it must be a group
|
// if a participant is quoted, then it must be a group
|
||||||
// hence, remoteJid of group must also be entered
|
// hence, remoteJid of group must also be entered
|
||||||
if(quoted.key.participant || quoted.participant) {
|
if(quoted.key.participant || quoted.participant) {
|
||||||
message[key].contextInfo.remoteJid = quoted.key.remoteJid
|
contextInfo.remoteJid = quoted.key.remoteJid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message[key].contextInfo = contextInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
|
|||||||
Reference in New Issue
Block a user