feat: implement tc token handling

TC token is required in certain cases to receive presence updates on chats
This commit is contained in:
Adhiraj Singh
2022-12-11 15:48:26 +05:30
parent a5d263d31b
commit 572d0f1dd6
2 changed files with 30 additions and 2 deletions

View File

@@ -494,14 +494,27 @@ export const makeChatsSocket = (config: SocketConfig) => {
}
}
const presenceSubscribe = (toJid: string) => (
/**
* @param toJid the jid to subscribe to
* @param tcToken token for subscription, use if present
*/
const presenceSubscribe = (toJid: string, tcToken?: Buffer) => (
sendNode({
tag: 'presence',
attrs: {
to: toJid,
id: generateMessageTag(),
type: 'subscribe'
}
},
content: tcToken
? [
{
tag: 'tctoken',
attrs: { },
content: tcToken
}
]
: undefined
})
)