diff --git a/src/Connection/chats.ts b/src/Connection/chats.ts index 1394c90..3cf8c34 100644 --- a/src/Connection/chats.ts +++ b/src/Connection/chats.ts @@ -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 diff --git a/src/Connection/messages.ts b/src/Connection/messages.ts index cbb4c32..08d1f16 100644 --- a/src/Connection/messages.ts +++ b/src/Connection/messages.ts @@ -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,