mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-20 20:49:14 +00:00
fix: don't get chat after accepting invite
This will now only return the chatId, since getting the chat at this point is unreliable.
This commit is contained in:
@@ -66,10 +66,9 @@ client.on('message', async msg => {
|
|||||||
}
|
}
|
||||||
} else if(msg.body.startsWith('!join ')) {
|
} else if(msg.body.startsWith('!join ')) {
|
||||||
const inviteCode = msg.body.split(' ')[1];
|
const inviteCode = msg.body.split(' ')[1];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const chat = await client.acceptInvite(inviteCode);
|
await client.acceptInvite(inviteCode);
|
||||||
msg.reply(`Joined *${chat.name}*!`);
|
msg.reply('Joined the group!');
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
msg.reply('That invite code seems to be invalid.');
|
msg.reply('That invite code seems to be invalid.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,12 +239,11 @@ class Client extends EventEmitter {
|
|||||||
* @param {string} inviteCode
|
* @param {string} inviteCode
|
||||||
*/
|
*/
|
||||||
async acceptInvite(inviteCode) {
|
async acceptInvite(inviteCode) {
|
||||||
const chat = await this.pupPage.evaluate(async inviteCode => {
|
const chatId = await this.pupPage.evaluate(async inviteCode => {
|
||||||
const chatId = await window.Store.Invite.sendJoinGroupViaInvite(inviteCode);
|
return await window.Store.Invite.sendJoinGroupViaInvite(inviteCode);
|
||||||
return window.WWebJS.getChat(chatId._serialized);
|
|
||||||
}, inviteCode);
|
}, inviteCode);
|
||||||
|
|
||||||
return ChatFactory.create(this.client, chat);
|
return chatId._serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user