fix: group_join event (#2320)
* added linked_group_join subtype * typo fixed from pr#2027 * fix: ESLint
This commit is contained in:
parent
8ff5bceca0
commit
dce964d934
2 changed files with 16 additions and 16 deletions
24
example.js
24
example.js
|
|
@ -313,28 +313,28 @@ client.on('contact_changed', async (message, oldId, newId, isContact) => {
|
||||||
`Their new phone number is ${newId.slice(0, -5)}.\n`);
|
`Their new phone number is ${newId.slice(0, -5)}.\n`);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about the {@name message}:
|
* Information about the @param {message}:
|
||||||
*
|
*
|
||||||
* 1. If a notification was emitted due to a group participant changing their phone number:
|
* 1. If a notification was emitted due to a group participant changing their phone number:
|
||||||
* {@name message.author} is a participant's id before the change.
|
* @param {message.author} is a participant's id before the change.
|
||||||
* {@name message.recipients[0]} is a participant's id after the change (a new one).
|
* @param {message.recipients[0]} is a participant's id after the change (a new one).
|
||||||
*
|
*
|
||||||
* 1.1 If the contact who changed their number WAS in the current user's contact list at the time of the change:
|
* 1.1 If the contact who changed their number WAS in the current user's contact list at the time of the change:
|
||||||
* {@name message.to} is a group chat id the event was emitted in.
|
* @param {message.to} is a group chat id the event was emitted in.
|
||||||
* {@name message.from} is a current user's id that got an notification message in the group.
|
* @param {message.from} is a current user's id that got an notification message in the group.
|
||||||
* Also the {@name message.fromMe} is TRUE.
|
* Also the @param {message.fromMe} is TRUE.
|
||||||
*
|
*
|
||||||
* 1.2 Otherwise:
|
* 1.2 Otherwise:
|
||||||
* {@name message.from} is a group chat id the event was emitted in.
|
* @param {message.from} is a group chat id the event was emitted in.
|
||||||
* {@name message.to} is @type {undefined}.
|
* @param {message.to} is @type {undefined}.
|
||||||
* Also {@name message.fromMe} is FALSE.
|
* Also @param {message.fromMe} is FALSE.
|
||||||
*
|
*
|
||||||
* 2. If a notification was emitted due to a contact changing their phone number:
|
* 2. If a notification was emitted due to a contact changing their phone number:
|
||||||
* {@name message.templateParams} is an array of two user's ids:
|
* @param {message.templateParams} is an array of two user's ids:
|
||||||
* the old (before the change) and a new one, stored in alphabetical order.
|
* the old (before the change) and a new one, stored in alphabetical order.
|
||||||
* {@name message.from} is a current user's id that has a chat with a user,
|
* @param {message.from} is a current user's id that has a chat with a user,
|
||||||
* whos phone number was changed.
|
* whos phone number was changed.
|
||||||
* {@name message.to} is a user's id (after the change), the current user has a chat with.
|
* @param {message.to} is a user's id (after the change), the current user has a chat with.
|
||||||
*/
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,7 @@ class Client extends EventEmitter {
|
||||||
await page.exposeFunction('onAddMessageEvent', msg => {
|
await page.exposeFunction('onAddMessageEvent', msg => {
|
||||||
if (msg.type === 'gp2') {
|
if (msg.type === 'gp2') {
|
||||||
const notification = new GroupNotification(this, msg);
|
const notification = new GroupNotification(this, msg);
|
||||||
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
if (['add', 'invite', 'linked_group_join'].includes(msg.subtype)) {
|
||||||
/**
|
/**
|
||||||
* Emitted when a user joins the chat via invite link or is added by an admin.
|
* Emitted when a user joins the chat via invite link or is added by an admin.
|
||||||
* @event Client#group_join
|
* @event Client#group_join
|
||||||
|
|
@ -396,18 +396,18 @@ class Client extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The event notification that is received when one of
|
* The event notification that is received when one of
|
||||||
* the group participants changes thier phone number.
|
* the group participants changes their phone number.
|
||||||
*/
|
*/
|
||||||
const isParticipant = msg.type === 'gp2' && msg.subtype === 'modify';
|
const isParticipant = msg.type === 'gp2' && msg.subtype === 'modify';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The event notification that is received when one of
|
* The event notification that is received when one of
|
||||||
* the contacts changes thier phone number.
|
* the contacts changes their phone number.
|
||||||
*/
|
*/
|
||||||
const isContact = msg.type === 'notification_template' && msg.subtype === 'change_number';
|
const isContact = msg.type === 'notification_template' && msg.subtype === 'change_number';
|
||||||
|
|
||||||
if (isParticipant || isContact) {
|
if (isParticipant || isContact) {
|
||||||
/** {@link GroupNotification} object does not provide enough information about this event, so a {@link Message} object is used. */
|
/** @type {GroupNotification} object does not provide enough information about this event, so a @type {Message} object is used. */
|
||||||
const message = new Message(this, msg);
|
const message = new Message(this, msg);
|
||||||
|
|
||||||
const newId = isParticipant ? msg.recipients[0] : msg.to;
|
const newId = isParticipant ? msg.recipients[0] : msg.to;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue