From 50feb3ceeaa1ed5a0648158f85a11853931725cb Mon Sep 17 00:00:00 2001 From: Edgard Date: Fri, 21 May 2021 14:15:55 -0300 Subject: [PATCH] feat: Added revokeGroupInviteLink function; --- src/api/layers/group.layer.ts | 14 ++++++++++++++ src/lib/wapi/functions/revoke-invite-link.js | 4 +++- src/types/WAPI.d.ts | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/api/layers/group.layer.ts b/src/api/layers/group.layer.ts index fe8ff9c73..c3ba47047 100644 --- a/src/api/layers/group.layer.ts +++ b/src/api/layers/group.layer.ts @@ -73,6 +73,20 @@ export class GroupLayer extends RetrieverLayer { chatId ); } + + /** + * Revokes group-invite link and generate new one. + * @category Group + * @param chatId + * @returns Invitation link + */ + public async revokeGroupInviteLink(chatId: string) { + return await this.page.evaluate( + (chatId) => WAPI.revokeGroupInviteLink(chatId), + chatId + ); + } + /** * Generates group-invite link * @category Group diff --git a/src/lib/wapi/functions/revoke-invite-link.js b/src/lib/wapi/functions/revoke-invite-link.js index 6f71467ff..aae72ac00 100644 --- a/src/lib/wapi/functions/revoke-invite-link.js +++ b/src/lib/wapi/functions/revoke-invite-link.js @@ -18,5 +18,7 @@ export async function revokeGroupInviteLink(chatId) { var chat = Store.Chat.get(chatId); if (!chat.isGroup) return false; - return await Store.GroupInvite.sendRevokeGroupInviteCode(chat.id); + const inviteCode = await Store.GroupInvite.sendRevokeGroupInviteCode(chat.id); + + return `https://chat.whatsapp.com/${inviteCode}`; } diff --git a/src/types/WAPI.d.ts b/src/types/WAPI.d.ts index c3e5d265c..7b395d1c7 100644 --- a/src/types/WAPI.d.ts +++ b/src/types/WAPI.d.ts @@ -130,6 +130,7 @@ interface WAPI { promoteParticipant: (groupId: string, contactId: string | string[]) => void; removeParticipant: (groupId: string, contactId: string | string[]) => void; reply: (to: string, content: string, quotedMsg: string) => Promise; + revokeGroupInviteLink: (chatId: string) => Promise; restartService: () => boolean; sendChatstate: (chatState: string, chatId: string) => void; sendContactVcard: (