Added muting, pinning chats

This commit is contained in:
Adhiraj Singh
2020-07-08 18:37:28 +05:30
parent 2018653bca
commit 583c2adf28
4 changed files with 74 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
import WAConnection from '../WAConnection/WAConnection'
import { MessageStatus, MessageStatusUpdate, PresenceUpdate, Presence } from './Constants'
import { MessageStatus, MessageStatusUpdate, PresenceUpdate, Presence, ChatModification } from './Constants'
import {
WAMessage,
WANode,
@@ -99,18 +99,6 @@ export default class WhatsAppWebBase extends WAConnection {
const json = ['query', { epoch: this.msgCount.toString(), type: 'chat' }, null]
return this.query(json, [WAMetric.group, WAFlag.ignore]) // this has to be an encrypted query
}
/**
* Archive a given chat
* @param jid the ID of the person/group you are archiving
*/
async archiveChat(jid: string) {
const json = [
'action',
{ epoch: this.msgCount.toString(), type: 'set' },
[['chat', { type: 'archive', jid: jid }, null]],
]
return this.queryExpecting200(json, [WAMetric.group, WAFlag.acknowledge]) as Promise<{ status: number }>
}
/**
* Check if your phone is connected
* @param timeoutMs max time for the phone to respond
@@ -189,8 +177,13 @@ export default class WhatsAppWebBase extends WAConnection {
}
return loadMessage() as Promise<void>
}
/** Generic function for action, set queries */
async setQuery (nodes: WANode[]) {
const json = ['action', {epoch: this.msgCount.toString(), type: 'set'}, nodes]
return this.queryExpecting200(json, [WAMetric.group, WAFlag.ignore]) as Promise<{status: number}>
}
/** Generic function for group queries */
groupQuery(type: string, jid?: string, subject?: string, participants?: string[]) {
async groupQuery(type: string, jid?: string, subject?: string, participants?: string[]) {
const json: WANode = [
'group',
{