mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: temp patch for button/list messages
This commit is contained in:
@@ -22,7 +22,7 @@ import {
|
||||
WAProto,
|
||||
WATextMessage,
|
||||
} from '../Types'
|
||||
import { jidNormalizedUser } from '../WABinary'
|
||||
import { isJidGroup, jidNormalizedUser } from '../WABinary'
|
||||
import { generateMessageID, unixTimestampSeconds } from './generics'
|
||||
import { downloadContentFromMessage, encryptedStream, generateThumbnail, getAudioDuration, MediaDownloadOptions } from './messages-media'
|
||||
|
||||
@@ -392,6 +392,7 @@ export const generateWAMessageContent = async(
|
||||
|
||||
m = {
|
||||
templateMessage: {
|
||||
fourRowTemplate: msg,
|
||||
hydratedTemplate: msg
|
||||
}
|
||||
}
|
||||
@@ -494,7 +495,7 @@ export const generateWAMessageFromContent = (
|
||||
message: message,
|
||||
messageTimestamp: timestamp,
|
||||
messageStubParameters: [],
|
||||
participant: jid.includes('@g.us') ? userJid : undefined,
|
||||
participant: isJidGroup(jid) ? userJid : undefined,
|
||||
status: WAMessageStatus.PENDING
|
||||
}
|
||||
return WAProto.WebMessageInfo.fromObject(messageJSON)
|
||||
@@ -717,4 +718,37 @@ export const assertMediaContent = (content: proto.IMessage | null | undefined) =
|
||||
}
|
||||
|
||||
return mediaContent
|
||||
}
|
||||
|
||||
|
||||
const generateContextInfo = () => {
|
||||
const info: proto.IMessageContextInfo = {
|
||||
deviceListMetadataVersion: 2,
|
||||
deviceListMetadata: { }
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
/**
|
||||
* this is an experimental patch to make buttons work
|
||||
* Don't know how it works, but it does for now
|
||||
*/
|
||||
export const patchMessageForMdIfRequired = (message: proto.IMessage) => {
|
||||
const requiresPatch = !!(
|
||||
message.buttonsMessage
|
||||
// || message.templateMessage
|
||||
|| message.listMessage
|
||||
)
|
||||
if(requiresPatch) {
|
||||
message = {
|
||||
viewOnceMessage: {
|
||||
message: {
|
||||
messageContextInfo: generateContextInfo(),
|
||||
...message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return message
|
||||
}
|
||||
Reference in New Issue
Block a user