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('chats.set', { chats, messages })
|
||||||
|
ev.emit('connection.update', { receivedPendingNotifications: true })
|
||||||
break
|
break
|
||||||
case proto.HistorySync.HistorySyncHistorySyncType.PUSH_NAME:
|
case proto.HistorySync.HistorySyncHistorySyncType.PUSH_NAME:
|
||||||
const contacts = item.pushnames.map(
|
const contacts = item.pushnames.map(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import { SocketConfig, MediaConnInfo, AnyMessageContent, MiscMessageGenerationOptions, WAMediaUploadFunction, MessageRelayOptions } from "../Types"
|
import { SocketConfig, MediaConnInfo, AnyMessageContent, MiscMessageGenerationOptions, WAMediaUploadFunction, MessageRelayOptions } from "../Types"
|
||||||
import { encodeWAMessage, generateMessageID, generateWAMessage } from "../Utils"
|
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 { proto } from "../../WAProto"
|
||||||
import { encryptSenderKeyMsgSignalProto, encryptSignalProto, extractDeviceJids, jidToSignalProtocolAddress, parseAndInjectE2ESession } from "../Utils/signal"
|
import { encryptSenderKeyMsgSignalProto, encryptSignalProto, extractDeviceJids, jidToSignalProtocolAddress, parseAndInjectE2ESession } from "../Utils/signal"
|
||||||
import { WA_DEFAULT_EPHEMERAL, DEFAULT_ORIGIN, MEDIA_PATH_MAP } from "../Defaults"
|
import { WA_DEFAULT_EPHEMERAL, DEFAULT_ORIGIN, MEDIA_PATH_MAP } from "../Defaults"
|
||||||
@@ -180,7 +180,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
const relayMessage = async(
|
const relayMessage = async(
|
||||||
jid: string,
|
jid: string,
|
||||||
message: proto.IMessage,
|
message: proto.IMessage,
|
||||||
{ messageId: msgId, cachedGroupMetadata }: MessageRelayOptions
|
{ messageId: msgId, additionalAttributes, cachedGroupMetadata }: MessageRelayOptions
|
||||||
) => {
|
) => {
|
||||||
const { user, server } = jidDecode(jid)
|
const { user, server } = jidDecode(jid)
|
||||||
const isGroup = server === 'g.us'
|
const isGroup = server === 'g.us'
|
||||||
@@ -281,7 +281,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
attrs: {
|
attrs: {
|
||||||
id: msgId,
|
id: msgId,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
to: destinationJid
|
to: destinationJid,
|
||||||
|
...(additionalAttributes || {})
|
||||||
},
|
},
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
@@ -393,7 +394,13 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
upload: waUploadToServer
|
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) {
|
if(config.emitOwnEvents) {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
ev.emit('messages.upsert', { messages: [fullMsg], type: 'append' })
|
ev.emit('messages.upsert', { messages: [fullMsg], type: 'append' })
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ export type AnyMessageContent = AnyRegularMessageContent | {
|
|||||||
|
|
||||||
export type MessageRelayOptions = {
|
export type MessageRelayOptions = {
|
||||||
messageId?: string
|
messageId?: string
|
||||||
|
additionalAttributes?: { [_: string]: string }
|
||||||
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadata | undefined>
|
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadata | undefined>
|
||||||
//cachedDevices?: (jid: string) => Promise<string[] | undefined>
|
//cachedDevices?: (jid: string) => Promise<string[] | undefined>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user