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 */
|
/** 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 = {
|
const chat: WAChat = {
|
||||||
jid,
|
jid,
|
||||||
name,
|
name,
|
||||||
t: unixTimestampSeconds(),
|
t: unixTimestampSeconds(),
|
||||||
messages: newMessagesDB(),
|
messages: newMessagesDB(),
|
||||||
count: 0,
|
count: 0,
|
||||||
modify_tag: '',
|
...(properties || {})
|
||||||
spam: 'false'
|
|
||||||
}
|
}
|
||||||
if(this.chats.insertIfAbsent(chat).length) {
|
if(this.chats.insertIfAbsent(chat).length) {
|
||||||
this.emit('chat-new', chat)
|
this.emit('chat-new', chat)
|
||||||
|
|||||||
@@ -88,13 +88,7 @@ export class WAConnection extends Base {
|
|||||||
metadata = await this.groupMetadata (gid)
|
metadata = await this.groupMetadata (gid)
|
||||||
this.logger.warn (`group ID switched from ${gid} to ${response.gid}`)
|
this.logger.warn (`group ID switched from ${gid} to ${response.gid}`)
|
||||||
}
|
}
|
||||||
await this.chatAdd(response.gid, title)
|
await this.chatAdd(response.gid, title, { metadata })
|
||||||
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 })
|
|
||||||
|
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -222,8 +222,8 @@ export interface WAChat {
|
|||||||
read_only?: 'true' | 'false'
|
read_only?: 'true' | 'false'
|
||||||
mute?: string
|
mute?: string
|
||||||
pin?: string
|
pin?: string
|
||||||
spam: 'false' | 'true'
|
spam?: 'false' | 'true'
|
||||||
modify_tag: string
|
modify_tag?: string
|
||||||
name?: string
|
name?: string
|
||||||
/** when ephemeral messages were toggled on */
|
/** when ephemeral messages were toggled on */
|
||||||
eph_setting_ts?: string
|
eph_setting_ts?: string
|
||||||
|
|||||||
Reference in New Issue
Block a user