mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
add index to chat modifications
This commit is contained in:
@@ -280,7 +280,7 @@ const makeChatsSocket = (config: SocketConfig) => {
|
||||
* Modify a given chat (archive, pin etc.)
|
||||
* @param jid the ID of the person/group you are modifiying
|
||||
*/
|
||||
modifyChat: async(jid: string, modification: ChatModification) => {
|
||||
modifyChat: async(jid: string, modification: ChatModification, index?: WAMessageKey) => {
|
||||
let chatAttrs: Attributes = { jid: jid }
|
||||
let data: BinaryNode[] | undefined = undefined
|
||||
const stamp = unixTimestampSeconds()
|
||||
@@ -322,8 +322,13 @@ const makeChatsSocket = (config: SocketConfig) => {
|
||||
))
|
||||
}
|
||||
|
||||
if(index) {
|
||||
chatAttrs.index = index.id
|
||||
chatAttrs.owner = index.fromMe ? 'true' : 'false'
|
||||
}
|
||||
|
||||
const node = new BinaryNode('chat', chatAttrs, data)
|
||||
const response = await setQuery ([node], [ WAMetric.chat, WAFlag.ignore ])
|
||||
const response = await setQuery([node], [ WAMetric.chat, WAFlag.ignore ])
|
||||
// apply it and emit events
|
||||
executeChatModification(node)
|
||||
return response
|
||||
|
||||
@@ -84,7 +84,13 @@ const makeMessagesSocket = (config: SocketConfig) => {
|
||||
const response: BinaryNode = await query ({
|
||||
json: new BinaryNode(
|
||||
'query',
|
||||
{type: 'media', index: message.key.id, owner: message.key.fromMe ? 'true' : 'false', jid: message.key.remoteJid, epoch: currentEpoch().toString()}
|
||||
{
|
||||
type: 'media',
|
||||
index: message.key.id,
|
||||
owner: message.key.fromMe ? 'true' : 'false',
|
||||
jid: message.key.remoteJid,
|
||||
epoch: currentEpoch().toString()
|
||||
}
|
||||
),
|
||||
binaryTag: [WAMetric.queryMedia, WAFlag.ignore],
|
||||
expect200: true,
|
||||
|
||||
Reference in New Issue
Block a user