diff --git a/docs/structures_Base.js.html b/docs/structures_Base.js.html index 4e70ed7..e9fe853 100644 --- a/docs/structures_Base.js.html +++ b/docs/structures_Base.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Base.js + whatsapp-web.js 1.19.2 » Source: structures/Base.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_BusinessContact.js.html b/docs/structures_BusinessContact.js.html index e7600cd..8599931 100644 --- a/docs/structures_BusinessContact.js.html +++ b/docs/structures_BusinessContact.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/BusinessContact.js + whatsapp-web.js 1.19.2 » Source: structures/BusinessContact.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Buttons.js.html b/docs/structures_Buttons.js.html index 3a79b8d..81e9157 100644 --- a/docs/structures_Buttons.js.html +++ b/docs/structures_Buttons.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Buttons.js + whatsapp-web.js 1.19.2 » Source: structures/Buttons.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Call.js.html b/docs/structures_Call.js.html index 2c64c0a..1ada572 100644 --- a/docs/structures_Call.js.html +++ b/docs/structures_Call.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Call.js + whatsapp-web.js 1.19.2 » Source: structures/Call.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Chat.js.html b/docs/structures_Chat.js.html index 0fab4cb..59f32bb 100644 --- a/docs/structures_Chat.js.html +++ b/docs/structures_Chat.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Chat.js + whatsapp-web.js 1.19.2 » Source: structures/Chat.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_ClientInfo.js.html b/docs/structures_ClientInfo.js.html index 4c205c7..8645f82 100644 --- a/docs/structures_ClientInfo.js.html +++ b/docs/structures_ClientInfo.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/ClientInfo.js + whatsapp-web.js 1.19.2 » Source: structures/ClientInfo.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Contact.js.html b/docs/structures_Contact.js.html index 2da1245..b220a2d 100644 --- a/docs/structures_Contact.js.html +++ b/docs/structures_Contact.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Contact.js + whatsapp-web.js 1.19.2 » Source: structures/Contact.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_GroupChat.js.html b/docs/structures_GroupChat.js.html index 7635f2e..fd3b90c 100644 --- a/docs/structures_GroupChat.js.html +++ b/docs/structures_GroupChat.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/GroupChat.js + whatsapp-web.js 1.19.2 » Source: structures/GroupChat.js @@ -15,7 +15,7 @@ @@ -90,10 +90,15 @@ class GroupChat extends Chat { * @returns {Promise<Object>} */ async addParticipants(participantIds) { - return await this.client.pupPage.evaluate((chatId, participantIds) => { + return await this.client.pupPage.evaluate(async (chatId, participantIds) => { const chatWid = window.Store.WidFactory.createWid(chatId); - const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p)); - return window.Store.GroupParticipants.sendAddParticipants(chatWid, participantWids); + const chat = await window.Store.Chat.find(chatWid); + const participants = await Promise.all(participantIds.map(async p => { + const wid = window.Store.WidFactory.createWid(p); + return await window.Store.Contact.get(wid); + })); + await window.Store.GroupParticipants.addParticipants(chat, participants); + return { status: 200 }; }, this.id._serialized, participantIds); } @@ -103,10 +108,14 @@ class GroupChat extends Chat { * @returns {Promise<Object>} */ async removeParticipants(participantIds) { - return await this.client.pupPage.evaluate((chatId, participantIds) => { + return await this.client.pupPage.evaluate(async (chatId, participantIds) => { const chatWid = window.Store.WidFactory.createWid(chatId); - const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p)); - return window.Store.GroupParticipants.sendRemoveParticipants(chatWid, participantWids); + const chat = await window.Store.Chat.find(chatWid); + const participants = participantIds.map(p => { + return chat.groupMetadata.participants.get(p); + }).filter(p => Boolean(p)); + await window.Store.GroupParticipants.removeParticipants(chat, participants); + return { status: 200 }; }, this.id._serialized, participantIds); } @@ -116,10 +125,14 @@ class GroupChat extends Chat { * @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful */ async promoteParticipants(participantIds) { - return await this.client.pupPage.evaluate((chatId, participantIds) => { + return await this.client.pupPage.evaluate(async (chatId, participantIds) => { const chatWid = window.Store.WidFactory.createWid(chatId); - const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p)); - return window.Store.GroupParticipants.sendPromoteParticipants(chatWid, participantWids); + const chat = await window.Store.Chat.find(chatWid); + const participants = participantIds.map(p => { + return chat.groupMetadata.participants.get(p); + }).filter(p => Boolean(p)); + await window.Store.GroupParticipants.promoteParticipants(chat, participants); + return { status: 200 }; }, this.id._serialized, participantIds); } @@ -129,10 +142,14 @@ class GroupChat extends Chat { * @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful */ async demoteParticipants(participantIds) { - return await this.client.pupPage.evaluate((chatId, participantIds) => { + return await this.client.pupPage.evaluate(async (chatId, participantIds) => { const chatWid = window.Store.WidFactory.createWid(chatId); - const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p)); - return window.Store.GroupParticipants.sendDemoteParticipants(chatWid, participantWids); + const chat = await window.Store.Chat.find(chatWid); + const participants = participantIds.map(p => { + return chat.groupMetadata.participants.get(p); + }).filter(p => Boolean(p)); + await window.Store.GroupParticipants.demoteParticipants(chat, participants); + return { status: 200 }; }, this.id._serialized, participantIds); } @@ -145,7 +162,8 @@ class GroupChat extends Chat { const success = await this.client.pupPage.evaluate(async (chatId, subject) => { const chatWid = window.Store.WidFactory.createWid(chatId); try { - return await window.Store.GroupUtils.sendSetGroupSubject(chatWid, subject); + await window.Store.GroupUtils.setGroupSubject(chatWid, subject); + return true; } catch (err) { if(err.name === 'ServerStatusCodeError') return false; throw err; @@ -167,7 +185,8 @@ class GroupChat extends Chat { const chatWid = window.Store.WidFactory.createWid(chatId); let descId = window.Store.GroupMetadata.get(chatWid).descId; try { - return await window.Store.GroupUtils.sendSetGroupDescription(chatWid, description, window.Store.MsgKey.newId(), descId); + await window.Store.GroupUtils.setGroupDescription(chatWid, description, window.Store.MsgKey.newId(), descId); + return true; } catch (err) { if(err.name === 'ServerStatusCodeError') return false; throw err; @@ -188,7 +207,8 @@ class GroupChat extends Chat { const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => { const chatWid = window.Store.WidFactory.createWid(chatId); try { - return await window.Store.GroupUtils.sendSetGroupProperty(chatWid, 'announcement', adminsOnly ? 1 : 0); + await window.Store.GroupUtils.setGroupProperty(chatWid, 'announcement', adminsOnly ? 1 : 0); + return true; } catch (err) { if(err.name === 'ServerStatusCodeError') return false; throw err; @@ -210,7 +230,8 @@ class GroupChat extends Chat { const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => { const chatWid = window.Store.WidFactory.createWid(chatId); try { - return await window.Store.GroupUtils.sendSetGroupProperty(chatWid, 'restrict', adminsOnly ? 1 : 0); + await window.Store.GroupUtils.setGroupProperty(chatWid, 'restrict', adminsOnly ? 1 : 0); + return true; } catch (err) { if(err.name === 'ServerStatusCodeError') return false; throw err; @@ -228,12 +249,12 @@ class GroupChat extends Chat { * @returns {Promise<string>} Group's invite code */ async getInviteCode() { - const code = await this.client.pupPage.evaluate(async chatId => { + const codeRes = await this.client.pupPage.evaluate(async chatId => { const chatWid = window.Store.WidFactory.createWid(chatId); - return window.Store.Invite.sendQueryGroupInviteCode(chatWid); + return window.Store.Invite.queryGroupInviteCode(chatWid); }, this.id._serialized); - return code; + return codeRes.code; } /** @@ -241,12 +262,12 @@ class GroupChat extends Chat { * @returns {Promise<string>} New invite code */ async revokeInvite() { - const code = await this.client.pupPage.evaluate(chatId => { + const codeRes = await this.client.pupPage.evaluate(chatId => { const chatWid = window.Store.WidFactory.createWid(chatId); - return window.Store.Invite.sendRevokeGroupInviteCode(chatWid); + return window.Store.Invite.resetGroupInviteCode(chatWid); }, this.id._serialized); - return code; + return codeRes.code; } /** @@ -254,9 +275,10 @@ class GroupChat extends Chat { * @returns {Promise} */ async leave() { - await this.client.pupPage.evaluate(chatId => { + await this.client.pupPage.evaluate(async chatId => { const chatWid = window.Store.WidFactory.createWid(chatId); - return window.Store.GroupUtils.sendExitGroup(chatWid); + const chat = await window.Store.Chat.find(chatWid); + return window.Store.GroupUtils.sendExitGroup(chat); }, this.id._serialized); } diff --git a/docs/structures_GroupNotification.js.html b/docs/structures_GroupNotification.js.html index 882f1cd..907cdba 100644 --- a/docs/structures_GroupNotification.js.html +++ b/docs/structures_GroupNotification.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/GroupNotification.js + whatsapp-web.js 1.19.2 » Source: structures/GroupNotification.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Label.js.html b/docs/structures_Label.js.html index 84fe4a5..9bdcc3f 100644 --- a/docs/structures_Label.js.html +++ b/docs/structures_Label.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Label.js + whatsapp-web.js 1.19.2 » Source: structures/Label.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_List.js.html b/docs/structures_List.js.html index 5b90208..c50fa7e 100644 --- a/docs/structures_List.js.html +++ b/docs/structures_List.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/List.js + whatsapp-web.js 1.19.2 » Source: structures/List.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Location.js.html b/docs/structures_Location.js.html index 5d66947..2c81b9d 100644 --- a/docs/structures_Location.js.html +++ b/docs/structures_Location.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Location.js + whatsapp-web.js 1.19.2 » Source: structures/Location.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Message.js.html b/docs/structures_Message.js.html index 0c4d051..0d8eb4f 100644 --- a/docs/structures_Message.js.html +++ b/docs/structures_Message.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Message.js + whatsapp-web.js 1.19.2 » Source: structures/Message.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_MessageMedia.js.html b/docs/structures_MessageMedia.js.html index 499f7cf..4dc3d5a 100644 --- a/docs/structures_MessageMedia.js.html +++ b/docs/structures_MessageMedia.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/MessageMedia.js + whatsapp-web.js 1.19.2 » Source: structures/MessageMedia.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Order.js.html b/docs/structures_Order.js.html index 9ad5d7e..fd44444 100644 --- a/docs/structures_Order.js.html +++ b/docs/structures_Order.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Order.js + whatsapp-web.js 1.19.2 » Source: structures/Order.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Payment.js.html b/docs/structures_Payment.js.html index e934dd1..ef6c307 100644 --- a/docs/structures_Payment.js.html +++ b/docs/structures_Payment.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Payment.js + whatsapp-web.js 1.19.2 » Source: structures/Payment.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_PrivateChat.js.html b/docs/structures_PrivateChat.js.html index b7af145..d95fc6e 100644 --- a/docs/structures_PrivateChat.js.html +++ b/docs/structures_PrivateChat.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/PrivateChat.js + whatsapp-web.js 1.19.2 » Source: structures/PrivateChat.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_PrivateContact.js.html b/docs/structures_PrivateContact.js.html index 7aec0d9..13abf4a 100644 --- a/docs/structures_PrivateContact.js.html +++ b/docs/structures_PrivateContact.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/PrivateContact.js + whatsapp-web.js 1.19.2 » Source: structures/PrivateContact.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Product.js.html b/docs/structures_Product.js.html index 9e78871..1591885 100644 --- a/docs/structures_Product.js.html +++ b/docs/structures_Product.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Product.js + whatsapp-web.js 1.19.2 » Source: structures/Product.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_ProductMetadata.js.html b/docs/structures_ProductMetadata.js.html index ba7f554..ac7fca6 100644 --- a/docs/structures_ProductMetadata.js.html +++ b/docs/structures_ProductMetadata.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/ProductMetadata.js + whatsapp-web.js 1.19.2 » Source: structures/ProductMetadata.js @@ -15,7 +15,7 @@ diff --git a/docs/structures_Reaction.js.html b/docs/structures_Reaction.js.html index 6b47024..0eb2f2c 100644 --- a/docs/structures_Reaction.js.html +++ b/docs/structures_Reaction.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: structures/Reaction.js + whatsapp-web.js 1.19.2 » Source: structures/Reaction.js @@ -15,7 +15,7 @@ diff --git a/docs/util_Constants.js.html b/docs/util_Constants.js.html index 12a26d5..c5ca2aa 100644 --- a/docs/util_Constants.js.html +++ b/docs/util_Constants.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: util/Constants.js + whatsapp-web.js 1.19.2 » Source: util/Constants.js @@ -15,7 +15,7 @@ diff --git a/docs/util_InterfaceController.js.html b/docs/util_InterfaceController.js.html index 02b7dc3..4de61c7 100644 --- a/docs/util_InterfaceController.js.html +++ b/docs/util_InterfaceController.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: util/InterfaceController.js + whatsapp-web.js 1.19.2 » Source: util/InterfaceController.js @@ -15,7 +15,7 @@ diff --git a/docs/util_Util.js.html b/docs/util_Util.js.html index 5f19a8f..ca4ad46 100644 --- a/docs/util_Util.js.html +++ b/docs/util_Util.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.19.1 » Source: util/Util.js + whatsapp-web.js 1.19.2 » Source: util/Util.js @@ -15,7 +15,7 @@ diff --git a/package.json b/package.json index a396b2d..40d37e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "whatsapp-web.js", - "version": "1.19.1", + "version": "1.19.2", "description": "Library for interacting with the WhatsApp Web API ", "main": "./index.js", "typings": "./index.d.ts",