Added method to update the profile name

This commit is contained in:
Edgard Messias
2020-12-14 18:01:50 -03:00
parent 523f0341ed
commit 14bf3a441a
4 changed files with 71 additions and 6 deletions

View File

@@ -76,10 +76,31 @@ export class WAConnection extends Base {
Buffer.from (status, 'utf-8')
]
]
)
)
this.emit ('contact-update', { jid: this.user.jid, status })
// emit deprecated
this.emit ('user-status-update', { jid: this.user.jid, status })
return response
}
async updateProfileName (name: string) {
const response = (await this.setQuery (
[
[
'profile',
{
name
},
null
]
]
)) as any as {status: number, pushname: string}
if (response.status === 200) {
this.user.name = response.pushname;
this.emit ('contact-update', { jid: this.user.jid, name })
}
return response
}
/** Get your contacts */
async getContacts() {
const json = ['query', { epoch: this.msgCount.toString(), type: 'contacts' }, null]