mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
WAChat update
This commit is contained in:
@@ -446,15 +446,14 @@ export class WAConnection extends Base {
|
||||
}
|
||||
}
|
||||
/** inserts an empty chat into the DB */
|
||||
protected chatAdd (jid: string, name?: string) {
|
||||
protected chatAdd (jid: string, name?: string, properties: Partial<WAChat> = {}) {
|
||||
const chat: WAChat = {
|
||||
jid,
|
||||
name,
|
||||
t: unixTimestampSeconds(),
|
||||
messages: newMessagesDB(),
|
||||
count: 0,
|
||||
modify_tag: '',
|
||||
spam: 'false'
|
||||
...(properties || {})
|
||||
}
|
||||
if(this.chats.insertIfAbsent(chat).length) {
|
||||
this.emit('chat-new', chat)
|
||||
|
||||
@@ -88,13 +88,7 @@ export class WAConnection extends Base {
|
||||
metadata = await this.groupMetadata (gid)
|
||||
this.logger.warn (`group ID switched from ${gid} to ${response.gid}`)
|
||||
}
|
||||
await this.chatAdd(response.gid, title)
|
||||
const chat = this.chats.get(response.gid)
|
||||
chat.metadata = metadata
|
||||
chat.name = title // in case the chat wasn't inserted
|
||||
|
||||
this.emit('chat-update', { jid: chat.jid, name: chat.name, metadata })
|
||||
|
||||
await this.chatAdd(response.gid, title, { metadata })
|
||||
return response
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -222,8 +222,8 @@ export interface WAChat {
|
||||
read_only?: 'true' | 'false'
|
||||
mute?: string
|
||||
pin?: string
|
||||
spam: 'false' | 'true'
|
||||
modify_tag: string
|
||||
spam?: 'false' | 'true'
|
||||
modify_tag?: string
|
||||
name?: string
|
||||
/** when ephemeral messages were toggled on */
|
||||
eph_setting_ts?: string
|
||||
|
||||
Reference in New Issue
Block a user