-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fixed send group invite link (#1991)
- Loading branch information
1 parent
ef0875a
commit 1978c5c
Showing
1 changed file
with
16 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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); | ||
} |