Skip to content

Commit

Permalink
fix: Fixed send group invite link (#1991)
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta authored Jun 6, 2024
1 parent ef0875a commit 1978c5c
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions src/chat/functions/sendGroupInviteMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,6 @@ export interface GroupInviteMessage extends SendMessageOptions {
* groupId: '789@g.us'
* }
* );
*
* // After a invite
* const result = await WPP.group.addParticipants('[email protected]', '[email protected]');
* const participant = result['[email protected]'];
* if (participant.invite_code) {
* WPP.chat.sendGroupInviteMessage(
* '123@c.us',
* {
* inviteCode: participant.invite_code,
* inviteCodeExpiration: participant.invite_code_exp,
* groupId: '789@g.us'
* }
* );
* }
* ```
*
* @category Message
Expand Down Expand Up @@ -88,16 +74,22 @@ export async function sendGroupInviteMessage(
} catch (error) {}
}
}

const inviteLink = `https://chat.whatsapp.com/${options.inviteCode}`;
const rawMessage: RawMessage = {
type: 'groups_v4_invite',
inviteGrpJpegThum: options.jpegThumbnail,
inviteCode: options.inviteCode,
inviteCodeExp: options.inviteCodeExpiration,
inviteGrp: options.groupId,
inviteGrpName: options.groupName,
comment: options.caption,
};

type: 'chat',
subtype: 'url',
thumbnail: options.jpegThumbnail,
thumbnailHeight: options.jpegThumbnail ? 100 : undefined,
thumbnailWidth: options.jpegThumbnail ? 100 : undefined,
title: options.groupName,
inviteGrpType: 'DEFAULT',
canonicalUrl: `https://chat.whatsapp.com/${options.inviteCode}`,
description: options.caption
? `${options.caption}\n${inviteLink}`
: inviteLink,
body: options.caption ? `${options.caption}\n${inviteLink}` : inviteLink,
matchedText: `https://chat.whatsapp.com/${options.inviteCode}`,
richPreviewType: 0,
} as any;
return await sendRawMessage(chatId, rawMessage, options);
}

0 comments on commit 1978c5c

Please sign in to comment.