Group fix

This commit is contained in:
Adhiraj
2020-07-12 21:49:50 +05:30
parent fe43125456
commit 2aca2f7485
3 changed files with 14 additions and 3 deletions

1
.gitignore vendored
View File

@@ -12,3 +12,4 @@ browser-messages.json
package-lock.json
package-lock.json
decoded-ws.json
auth_info2.json

View File

@@ -212,13 +212,14 @@ export default class WhatsAppWebBase extends WAConnection {
const query = ['query', {type: 'group', jid: jid, epoch: this.msgCount.toString()}, null]
const response = await this.queryExpecting200(query, [WAMetric.group, WAFlag.ignore])
const json = response[2][0]
const creatorDesc = json[1]
const participants = json[2] ? json[2].filter (item => item[0] === 'participant') : []
const description = json[2] ? json[2].find (item => item[0] === 'description') : null
return {
id: jid,
owner: json[1].creator,
creator: json[1].creator,
creation: parseInt(json[1].create),
owner: creatorDesc?.creator,
creator: creatorDesc?.creator,
creation: parseInt(creatorDesc?.create),
subject: null,
desc: description ? description[2].toString('utf-8') : null,
participants: participants.map (item => ({ id: item[1].jid, isAdmin: item[1].type==='admin' }))

View File

@@ -69,6 +69,15 @@ WAClientTest('Messages', (client) => {
await createTimeout (2000)
await client.clearMessage (messages[0].key)
})
it ('should load convo', async () => {
const [chats] = await client.receiveChatsAndContacts ()
for (var i in chats) {
if (chats[i].jid.includes('@g.us')) {
console.log (chats[i].jid)
const data = await client.groupCreatorAndParticipants (chats[i].jid)
}
}
})
})
describe('Validate WhatsApp IDs', () => {