add index to chat modifications

This commit is contained in:
Adhiraj Singh
2021-08-18 11:25:56 +05:30
parent a0bb9717b5
commit 4638f1261d
2 changed files with 14 additions and 3 deletions

View File

@@ -280,7 +280,7 @@ const makeChatsSocket = (config: SocketConfig) => {
* Modify a given chat (archive, pin etc.) * Modify a given chat (archive, pin etc.)
* @param jid the ID of the person/group you are modifiying * @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 chatAttrs: Attributes = { jid: jid }
let data: BinaryNode[] | undefined = undefined let data: BinaryNode[] | undefined = undefined
const stamp = unixTimestampSeconds() 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 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 // apply it and emit events
executeChatModification(node) executeChatModification(node)
return response return response

View File

@@ -84,7 +84,13 @@ const makeMessagesSocket = (config: SocketConfig) => {
const response: BinaryNode = await query ({ const response: BinaryNode = await query ({
json: new BinaryNode( json: new BinaryNode(
'query', '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], binaryTag: [WAMetric.queryMedia, WAFlag.ignore],
expect200: true, expect200: true,