mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
delete message fix
This commit is contained in:
@@ -222,6 +222,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
}
|
||||
)
|
||||
ev.emit('chats.set', { chats, messages })
|
||||
ev.emit('connection.update', { receivedPendingNotifications: true })
|
||||
break
|
||||
case proto.HistorySync.HistorySyncHistorySyncType.PUSH_NAME:
|
||||
const contacts = item.pushnames.map(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
import { SocketConfig, MediaConnInfo, AnyMessageContent, MiscMessageGenerationOptions, WAMediaUploadFunction, MessageRelayOptions } from "../Types"
|
||||
import { encodeWAMessage, generateMessageID, generateWAMessage } from "../Utils"
|
||||
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, jidDecode, jidEncode, jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary'
|
||||
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, jidDecode, jidEncode, jidNormalizedUser, S_WHATSAPP_NET, BinaryNodeAttributes } from '../WABinary'
|
||||
import { proto } from "../../WAProto"
|
||||
import { encryptSenderKeyMsgSignalProto, encryptSignalProto, extractDeviceJids, jidToSignalProtocolAddress, parseAndInjectE2ESession } from "../Utils/signal"
|
||||
import { WA_DEFAULT_EPHEMERAL, DEFAULT_ORIGIN, MEDIA_PATH_MAP } from "../Defaults"
|
||||
@@ -180,7 +180,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
const relayMessage = async(
|
||||
jid: string,
|
||||
message: proto.IMessage,
|
||||
{ messageId: msgId, cachedGroupMetadata }: MessageRelayOptions
|
||||
{ messageId: msgId, additionalAttributes, cachedGroupMetadata }: MessageRelayOptions
|
||||
) => {
|
||||
const { user, server } = jidDecode(jid)
|
||||
const isGroup = server === 'g.us'
|
||||
@@ -281,7 +281,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
attrs: {
|
||||
id: msgId,
|
||||
type: 'text',
|
||||
to: destinationJid
|
||||
to: destinationJid,
|
||||
...(additionalAttributes || {})
|
||||
},
|
||||
content: [
|
||||
{
|
||||
@@ -393,7 +394,13 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
upload: waUploadToServer
|
||||
}
|
||||
)
|
||||
await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id! })
|
||||
const additionalAttributes: BinaryNodeAttributes = { }
|
||||
// required for delete
|
||||
if('delete' in content) {
|
||||
additionalAttributes.edit = '7'
|
||||
}
|
||||
|
||||
await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id!, additionalAttributes })
|
||||
if(config.emitOwnEvents) {
|
||||
process.nextTick(() => {
|
||||
ev.emit('messages.upsert', { messages: [fullMsg], type: 'append' })
|
||||
|
||||
@@ -107,6 +107,7 @@ export type AnyMessageContent = AnyRegularMessageContent | {
|
||||
|
||||
export type MessageRelayOptions = {
|
||||
messageId?: string
|
||||
additionalAttributes?: { [_: string]: string }
|
||||
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadata | undefined>
|
||||
//cachedDevices?: (jid: string) => Promise<string[] | undefined>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user