Skip to content

Commit

Permalink
feat: Added revokeGroupInviteLink function;
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed May 21, 2021
1 parent 597715b commit 50feb3c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/api/layers/group.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/lib/wapi/functions/revoke-invite-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
1 change: 1 addition & 0 deletions src/types/WAPI.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
revokeGroupInviteLink: (chatId: string) => Promise<string>;
restartService: () => boolean;
sendChatstate: (chatState: string, chatId: string) => void;
sendContactVcard: (
Expand Down

0 comments on commit 50feb3c

Please sign in to comment.