Skip to content

Commit

Permalink
fix: Fixed getGroupInviteLink function (fix #214)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed May 21, 2021
1 parent 0f11152 commit 597715b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/lib/wapi/functions/get-group-invite-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@

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}`;
if (!chat.isGroup) {
return '';
}
let inviteCode = '';

if (chat.groupMetadata && chat.groupMetadata.inviteCode) {
inviteCode = chat.groupMetadata.inviteCode;
} else {
inviteCode = await Store.GroupInvite.sendQueryGroupInviteCode(chat.id);
}

return `https://chat.whatsapp.com/${inviteCode}`;
}
3 changes: 1 addition & 2 deletions src/lib/wapi/functions/revoke-invite-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@
export async function revokeGroupInviteLink(chatId) {
var chat = Store.Chat.get(chatId);
if (!chat.isGroup) return false;
await Store.GroupInvite.revokeGroupInvite(chat);
return true;
return await Store.GroupInvite.sendRevokeGroupInviteCode(chat.id);
}
2 changes: 1 addition & 1 deletion src/lib/wapi/store/store-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const storeObjects = [
},
{
id: 'GroupInvite',
conditions: (module) => (module.queryGroupInviteCode ? module : null),
conditions: (module) => (module.sendQueryGroupInviteCode ? module : null),
},
{
id: 'Wap',
Expand Down

0 comments on commit 597715b

Please sign in to comment.