diff --git a/src/api/layers/group.layer.ts b/src/api/layers/group.layer.ts index 4d6994947..fdaad5db5 100644 --- a/src/api/layers/group.layer.ts +++ b/src/api/layers/group.layer.ts @@ -115,6 +115,18 @@ export class GroupLayer extends RetrieverLayer { return Promise.all(actions); } + /** + * Reset group invitation link + * @param chatId + * @returns boolean + */ + public async revokeGroupInviteLink(chatId: string) { + return await this.page.evaluate( + (chatId) => WAPI.revokeGroupInviteLink(chatId), + chatId + ); + } + /** * Generates group-invite link * @param chatId diff --git a/src/lib/wapi/functions/get-group-invite-link.js b/src/lib/wapi/functions/get-group-invite-link.js index ae5702f23..982927a51 100644 --- a/src/lib/wapi/functions/get-group-invite-link.js +++ b/src/lib/wapi/functions/get-group-invite-link.js @@ -55,6 +55,6 @@ MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM export async function getGroupInviteLink(chatId) { var chat = Store.Chat.get(chatId); if (!chat.isGroup) return ''; - await Store.GroupInvite.queryGroupInviteCode(chat); - return `https://chat.whatsapp.com/${chat.inviteCode}`; + const code = Store.GroupInvite.sendQueryGroupInviteCode(chat.id); + return `https://chat.whatsapp.com/${code}`; } diff --git a/src/lib/wapi/functions/revoke-invite-link.js b/src/lib/wapi/functions/revoke-invite-link.js index 7f7a4b613..8ace3ea44 100644 --- a/src/lib/wapi/functions/revoke-invite-link.js +++ b/src/lib/wapi/functions/revoke-invite-link.js @@ -52,9 +52,9 @@ MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNMMNMNMMMNMMNNMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNMMNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM */ -export async function revokeGroupInviteLink(chatId) { +async function revokeGroupInviteLink(chatId) { var chat = Store.Chat.get(chatId); if (!chat.isGroup) return false; - await Store.GroupInvite.revokeGroupInvite(chat); + await Store.GroupInvite.sendRevokeGroupInviteCode(chat.id); return true; } diff --git a/src/lib/wapi/store/store-objects.js b/src/lib/wapi/store/store-objects.js index f7ee07f4f..4b8ef66f7 100644 --- a/src/lib/wapi/store/store-objects.js +++ b/src/lib/wapi/store/store-objects.js @@ -78,7 +78,10 @@ export const storeObjects = [ }, { id: 'GroupInvite', - conditions: (module) => (module.queryGroupInviteCode ? module : null), + conditions: (module) => + module.sendQueryGroupInviteCode && module.sendRevokeGroupInviteCode + ? module + : null, }, { id: 'Wap', diff --git a/src/types/WAPI.d.ts b/src/types/WAPI.d.ts index b73a526a5..3d853447c 100644 --- a/src/types/WAPI.d.ts +++ b/src/types/WAPI.d.ts @@ -112,6 +112,7 @@ interface WAPI { getGroupAdmins: (groupId: string) => Contact[]; getGroupInfoFromInviteLink: (inviteCode: string) => Promise; getGroupInviteLink: (chatId: string) => Promise; + revokeGroupInviteLink: (chatId: string) => Promise; getGroupParticipantIDs: (groupId: string) => Id[]; getHost: () => HostDevice; getListMute: (type?: string) => object;