Skip to content

Commit

Permalink
fix: RevokeGroup and getGroupInviteLink
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Jun 3, 2021
1 parent da56acb commit 55e1310
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/api/layers/group.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/lib/wapi/functions/get-group-invite-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
4 changes: 2 additions & 2 deletions src/lib/wapi/functions/revoke-invite-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
5 changes: 4 additions & 1 deletion src/lib/wapi/store/store-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions src/types/WAPI.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ interface WAPI {
getGroupAdmins: (groupId: string) => Contact[];
getGroupInfoFromInviteLink: (inviteCode: string) => Promise<string | boolean>;
getGroupInviteLink: (chatId: string) => Promise<string>;
revokeGroupInviteLink: (chatId: string) => Promise<boolean>;
getGroupParticipantIDs: (groupId: string) => Id[];
getHost: () => HostDevice;
getListMute: (type?: string) => object;
Expand Down

1 comment on commit 55e1310

@jonalan7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.