mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Archive bug fix + Delete bug fix + assert deprecation update
This commit is contained in:
@@ -108,16 +108,6 @@ export class WAConnection extends Base {
|
||||
}
|
||||
/** Query broadcast list info */
|
||||
async getBroadcastListInfo(jid: string) { return this.query({json: ['query', 'contact', jid], expect200: true }) as Promise<WABroadcastListInfo> }
|
||||
/** Delete the chat of a given ID */
|
||||
async deleteChat (jid: string) {
|
||||
const response = await this.setQuery ([ ['chat', {type: 'delete', jid: jid}, null] ], [12, WAFlag.ignore])
|
||||
const chat = this.chats.get (jid)
|
||||
if (chat) {
|
||||
this.chats.delete (chat)
|
||||
this.emit ('chat-update', { jid, delete: 'true' })
|
||||
}
|
||||
return response
|
||||
}
|
||||
/**
|
||||
* Load chats in a paginated manner + gets the profile picture
|
||||
* @param before chats before the given cursor
|
||||
|
||||
@@ -334,13 +334,20 @@ export class WAConnection extends Base {
|
||||
await this.relayWAMessage (waMessage)
|
||||
return waMessage
|
||||
}
|
||||
/**
|
||||
* Delete the chat of a given ID
|
||||
* @deprecated -- use `modifyChat(jid, 'delete')` instead
|
||||
* */
|
||||
deleteChat (jid: string) {
|
||||
return this.modifyChat(jid, 'delete')
|
||||
}
|
||||
/**
|
||||
* Modify a given chat (archive, pin etc.)
|
||||
* @param jid the ID of the person/group you are modifiying
|
||||
* @param durationMs only for muting, how long to mute the chat for
|
||||
*/
|
||||
@Mutex ((jid, type) => jid+type)
|
||||
async modifyChat (jid: string, type: ChatModification, durationMs?: number) {
|
||||
async modifyChat (jid: string, type: ChatModification | (keyof typeof ChatModification), durationMs?: number) {
|
||||
jid = whatsappID (jid)
|
||||
const chat = this.assertChatGet (jid)
|
||||
|
||||
@@ -373,7 +380,7 @@ export class WAConnection extends Base {
|
||||
chatAttrs.owner = msg.key.fromMe.toString()
|
||||
}
|
||||
if (isGroupID(jid)) {
|
||||
chatAttrs.participant = this.user?.jid
|
||||
chatAttrs.participant = whatsappID(msg.participant || msg.key.participant)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@@ -310,7 +310,8 @@ export enum ChatModification {
|
||||
pin='pin',
|
||||
unpin='unpin',
|
||||
mute='mute',
|
||||
unmute='unmute'
|
||||
unmute='unmute',
|
||||
delete='delete'
|
||||
}
|
||||
export const HKDFInfoKeys = {
|
||||
[MessageType.image]: 'WhatsApp Image Keys',
|
||||
|
||||
Reference in New Issue
Block a user