Presence fixes

This commit is contained in:
Adhiraj Singh
2020-11-24 18:56:07 +05:30
parent cd90d66c5e
commit 242328abdc
7 changed files with 74 additions and 38 deletions

View File

@@ -51,18 +51,15 @@ export class WAConnection extends Base {
* @param jid the ID of the person/group who you are updating
* @param type your presence
*/
updatePresence = (jid: string | null, type: Presence) =>
this.query(
{
json: [
'action',
{ epoch: this.msgCount.toString(), type: 'set' },
[['presence', { type: type, to: jid }, null]],
],
binaryTags: [WAMetric.group, WAFlag.acknowledge],
expect200: true
}
) as Promise<{status: number}>
updatePresence = (jid: string | null, type: Presence) => this.sendBinary(
[ 'action',
{epoch: this.msgCount.toString(), type: 'set'},
[ ['presence', { type: type, to: jid }, null] ]
],
[WAMetric.presence, WAFlag[type] ], // weird stuff WA does
undefined,
true
)
/** Request an update on the presence of a user */
requestPresenceUpdate = async (jid: string) => this.query({ json: ['action', 'presence', 'subscribe', jid] })
/** Query the status of the person (see groupMetadata() for groups) */