chore(v1.34.7): bump version and generate docs
This commit is contained in:
parent
211205363c
commit
f935b50011
77 changed files with 5207 additions and 2669 deletions
262
docs/structures_Channel.js.html
generated
262
docs/structures_Channel.js.html
generated
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.34.6 » Source: structures/Channel.js</title>
|
||||
<title>whatsapp-web.js 1.34.7 » Source: structures/Channel.js</title>
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||
<div id="jsdoc-navbar-container">
|
||||
<div id="jsdoc-navbar-content">
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>34.<wbr>6</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>34.<wbr>7</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
@ -68,11 +68,12 @@ class Channel extends Base {
|
|||
*/
|
||||
this.name = data.name;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The channel description
|
||||
* @type {string}
|
||||
*/
|
||||
this.description = data.channelMetadata.description;
|
||||
this.description =
|
||||
data.channelMetadata?.description ?? data.description ?? '';
|
||||
|
||||
/**
|
||||
* Indicates if it is a Channel
|
||||
|
|
@ -120,7 +121,9 @@ class Channel extends Base {
|
|||
* Last message in the channel
|
||||
* @type {Message}
|
||||
*/
|
||||
this.lastMessage = data.lastMessage ? new Message(super.client, data.lastMessage) : undefined;
|
||||
this.lastMessage = data.lastMessage
|
||||
? new Message(super.client, data.lastMessage)
|
||||
: undefined;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
|
@ -131,58 +134,82 @@ class Channel extends Base {
|
|||
* @returns {Promise&lt;Array&lt;{contact: Contact, role: string}>>} Returns an array of objects that handle the subscribed contacts and their roles in the channel
|
||||
*/
|
||||
async getSubscribers(limit) {
|
||||
return await this.client.pupPage.evaluate(async (channelId, limit) => {
|
||||
const channel = await window.WWebJS.getChat(channelId, { getAsModel: false });
|
||||
if (!channel) return [];
|
||||
!limit &amp;&amp; (limit = window.Store.ChannelUtils.getMaxSubscriberNumber());
|
||||
const response = await window.Store.ChannelSubscribers.mexFetchNewsletterSubscribers(channelId, limit);
|
||||
const contacts = window.Store.ChannelSubscribers.getSubscribersInContacts(response.subscribers);
|
||||
return Promise.all(contacts.map((obj) => ({
|
||||
...obj,
|
||||
contact: window.WWebJS.getContactModel(obj.contact)
|
||||
})));
|
||||
}, this.id._serialized, limit);
|
||||
return await this.client.pupPage.evaluate(
|
||||
async (channelId, limit) => {
|
||||
const channel = await window.WWebJS.getChat(channelId, {
|
||||
getAsModel: false,
|
||||
});
|
||||
if (!channel) return [];
|
||||
!limit &amp;&amp;
|
||||
(limit = window
|
||||
.require('WAWebNewsletterGatingUtils')
|
||||
.getMaxSubscriberNumber());
|
||||
const response = await window
|
||||
.require('WAWebMexFetchNewsletterSubscribersJob')
|
||||
.mexFetchNewsletterSubscribers(channelId, limit);
|
||||
const contacts = window
|
||||
.require('WAWebNewsletterSubscriberListAction')
|
||||
.getSubscribersInContacts(response.subscribers);
|
||||
return Promise.all(
|
||||
contacts.map((obj) => ({
|
||||
...obj,
|
||||
contact: window.WWebJS.getContactModel(obj.contact),
|
||||
})),
|
||||
);
|
||||
},
|
||||
this.id._serialized,
|
||||
limit,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the channel subject
|
||||
* @param {string} newSubject
|
||||
* @param {string} newSubject
|
||||
* @returns {Promise&lt;boolean>} Returns true if the subject was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setSubject(newSubject) {
|
||||
const success = await this._setChannelMetadata({ name: newSubject }, { editName: true });
|
||||
const success = await this._setChannelMetadata(
|
||||
{ name: newSubject },
|
||||
{ editName: true },
|
||||
);
|
||||
success &amp;&amp; (this.name = newSubject);
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the channel description
|
||||
* @param {string} newDescription
|
||||
* @param {string} newDescription
|
||||
* @returns {Promise&lt;boolean>} Returns true if the operation completed successfully, false otherwise
|
||||
*/
|
||||
async setDescription(newDescription) {
|
||||
const success = await this._setChannelMetadata({ description: newDescription }, { editDescription: true });
|
||||
const success = await this._setChannelMetadata(
|
||||
{ description: newDescription },
|
||||
{ editDescription: true },
|
||||
);
|
||||
success &amp;&amp; (this.description = newDescription);
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the channel profile picture
|
||||
* @param {MessageMedia} newProfilePicture
|
||||
* @param {MessageMedia} newProfilePicture
|
||||
* @returns {Promise&lt;boolean>} Returns true if the operation completed successfully, false otherwise
|
||||
*/
|
||||
async setProfilePicture(newProfilePicture) {
|
||||
return await this._setChannelMetadata({ picture: newProfilePicture }, { editPicture: true });
|
||||
return await this._setChannelMetadata(
|
||||
{ picture: newProfilePicture },
|
||||
{ editPicture: true },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates available reactions to use in the channel
|
||||
*
|
||||
*
|
||||
* Valid values for passing to the method are:
|
||||
* 0 for NONE reactions to be avaliable
|
||||
* 1 for BASIC reactions to be available: 👍, ❤️, 😂, 😮, 😢, 🙏
|
||||
* 2 for ALL reactions to be available
|
||||
* @param {number} reactionCode
|
||||
* @param {number} reactionCode
|
||||
* @returns {Promise&lt;boolean>} Returns true if the operation completed successfully, false otherwise
|
||||
*/
|
||||
async setReactionSetting(reactionCode) {
|
||||
|
|
@ -190,11 +217,11 @@ class Channel extends Base {
|
|||
const reactionMapper = {
|
||||
0: 3,
|
||||
1: 1,
|
||||
2: 0
|
||||
2: 0,
|
||||
};
|
||||
const success = await this._setChannelMetadata(
|
||||
{ reactionCodesSetting: reactionMapper[reactionCode] },
|
||||
{ editReactionCodesSetting: true }
|
||||
{ editReactionCodesSetting: true },
|
||||
);
|
||||
success &amp;&amp; (this.channelMetadata.reactionCodesSetting = reactionCode);
|
||||
return success;
|
||||
|
|
@ -212,7 +239,7 @@ class Channel extends Base {
|
|||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unmutes the channel
|
||||
* @returns {Promise&lt;boolean>} Returns true if the operation completed successfully, false otherwise
|
||||
|
|
@ -260,11 +287,15 @@ class Channel extends Base {
|
|||
/**
|
||||
* Sends a channel admin invitation to a user, allowing them to become an admin of the channel
|
||||
* @param {string} chatId The ID of a user to send the channel admin invitation to
|
||||
* @param {SendChannelAdminInviteOptions} options
|
||||
* @param {SendChannelAdminInviteOptions} options
|
||||
* @returns {Promise&lt;boolean>} Returns true if an invitation was sent successfully, false otherwise
|
||||
*/
|
||||
async sendChannelAdminInvite(chatId, options = {}) {
|
||||
return this.client.sendChannelAdminInvite(chatId, this.id._serialized, options);
|
||||
return this.client.sendChannelAdminInvite(
|
||||
chatId,
|
||||
this.id._serialized,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -281,7 +312,10 @@ class Channel extends Base {
|
|||
* @returns {Promise&lt;boolean>} Returns true if the operation completed successfully, false otherwise
|
||||
*/
|
||||
async revokeChannelAdminInvite(userId) {
|
||||
return this.client.revokeChannelAdminInvite(this.id._serialized, userId);
|
||||
return this.client.revokeChannelAdminInvite(
|
||||
this.id._serialized,
|
||||
userId,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -307,7 +341,11 @@ class Channel extends Base {
|
|||
* @returns {Promise&lt;boolean>} Returns true if the operation completed successfully, false otherwise
|
||||
*/
|
||||
async transferChannelOwnership(newOwnerId, options = {}) {
|
||||
return this.client.transferChannelOwnership(this.id._serialized, newOwnerId, options);
|
||||
return this.client.transferChannelOwnership(
|
||||
this.id._serialized,
|
||||
newOwnerId,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -318,36 +356,50 @@ class Channel extends Base {
|
|||
* @returns {Promise&lt;Array&lt;Message>>}
|
||||
*/
|
||||
async fetchMessages(searchOptions) {
|
||||
let messages = await this.client.pupPage.evaluate(async (channelId, searchOptions) => {
|
||||
const msgFilter = (m) => {
|
||||
if (m.isNotification || m.type === 'newsletter_notification') {
|
||||
return false; // dont include notification messages
|
||||
}
|
||||
if (searchOptions &amp;&amp; searchOptions.fromMe !== undefined &amp;&amp; m.id.fromMe !== searchOptions.fromMe) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
let messages = await this.client.pupPage.evaluate(
|
||||
async (channelId, searchOptions) => {
|
||||
const msgFilter = (m) => {
|
||||
if (
|
||||
m.isNotification ||
|
||||
m.type === 'newsletter_notification'
|
||||
) {
|
||||
return false; // dont include notification messages
|
||||
}
|
||||
if (
|
||||
searchOptions &amp;&amp;
|
||||
searchOptions.fromMe !== undefined &amp;&amp;
|
||||
m.id.fromMe !== searchOptions.fromMe
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const channel = await window.WWebJS.getChat(channelId, { getAsModel: false });
|
||||
let msgs = channel.msgs.getModelsArray().filter(msgFilter);
|
||||
const channel = await window.WWebJS.getChat(channelId, {
|
||||
getAsModel: false,
|
||||
});
|
||||
let msgs = channel.msgs.getModelsArray().filter(msgFilter);
|
||||
|
||||
if (searchOptions &amp;&amp; searchOptions.limit > 0) {
|
||||
while (msgs.length &lt; searchOptions.limit) {
|
||||
const loadedMessages = await window.Store.ConversationMsgs.loadEarlierMsgs(channel);
|
||||
if (!loadedMessages || !loadedMessages.length) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
if (searchOptions &amp;&amp; searchOptions.limit > 0) {
|
||||
while (msgs.length &lt; searchOptions.limit) {
|
||||
const loadedMessages = await window
|
||||
.require('WAWebChatLoadMessages')
|
||||
.loadEarlierMsgs({ chat: channel });
|
||||
if (!loadedMessages || !loadedMessages.length) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
}
|
||||
|
||||
if (msgs.length > searchOptions.limit) {
|
||||
msgs.sort((a, b) => (a.t > b.t ? 1 : -1));
|
||||
msgs = msgs.splice(msgs.length - searchOptions.limit);
|
||||
}
|
||||
}
|
||||
|
||||
if (msgs.length > searchOptions.limit) {
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
msgs = msgs.splice(msgs.length - searchOptions.limit);
|
||||
}
|
||||
}
|
||||
|
||||
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
||||
|
||||
}, this.id._serialized, searchOptions);
|
||||
return msgs.map((m) => window.WWebJS.getMessageModel(m));
|
||||
},
|
||||
this.id._serialized,
|
||||
searchOptions,
|
||||
);
|
||||
|
||||
return messages.map((msg) => new Message(this.client, msg));
|
||||
}
|
||||
|
|
@ -367,27 +419,39 @@ class Channel extends Base {
|
|||
* @returns {Promise&lt;boolean>} Returns true if the operation completed successfully, false otherwise
|
||||
*/
|
||||
async _setChannelMetadata(value, property) {
|
||||
return await this.client.pupPage.evaluate(async (channelId, value, property) => {
|
||||
const channel = await window.WWebJS.getChat(channelId, { getAsModel: false });
|
||||
if (!channel) return false;
|
||||
if (property.editPicture) {
|
||||
value.picture = value.picture
|
||||
? await window.WWebJS.cropAndResizeImage(value.picture, {
|
||||
asDataUrl: true,
|
||||
mimetype: 'image/jpeg',
|
||||
size: 640,
|
||||
quality: 1
|
||||
})
|
||||
: null;
|
||||
}
|
||||
try {
|
||||
await window.Store.ChannelUtils.editNewsletterMetadataAction(channel, property, value);
|
||||
return true;
|
||||
} catch (err) {
|
||||
if (err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, value, property);
|
||||
return await this.client.pupPage.evaluate(
|
||||
async (channelId, value, property) => {
|
||||
const channel = await window.WWebJS.getChat(channelId, {
|
||||
getAsModel: false,
|
||||
});
|
||||
if (!channel) return false;
|
||||
if (property.editPicture) {
|
||||
value.picture = value.picture
|
||||
? await window.WWebJS.cropAndResizeImage(
|
||||
value.picture,
|
||||
{
|
||||
asDataUrl: true,
|
||||
mimetype: 'image/jpeg',
|
||||
size: 640,
|
||||
quality: 1,
|
||||
},
|
||||
)
|
||||
: null;
|
||||
}
|
||||
try {
|
||||
await window
|
||||
.require('WAWebEditNewsletterMetadataAction')
|
||||
.editNewsletterMetadataAction(channel, property, value);
|
||||
return true;
|
||||
} catch (err) {
|
||||
if (err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
this.id._serialized,
|
||||
value,
|
||||
property,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -396,17 +460,35 @@ class Channel extends Base {
|
|||
* @returns {Promise&lt;boolean>} Returns true if the operation completed successfully, false otherwise
|
||||
*/
|
||||
async _muteUnmuteChannel(action) {
|
||||
return await this.client.pupPage.evaluate(async (channelId, action) => {
|
||||
try {
|
||||
action === 'MUTE'
|
||||
? await window.Store.ChannelUtils.muteNewsletter([channelId])
|
||||
: await window.Store.ChannelUtils.unmuteNewsletter([channelId]);
|
||||
return true;
|
||||
} catch (err) {
|
||||
if (err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, action);
|
||||
return await this.client.pupPage.evaluate(
|
||||
async (channelId, action) => {
|
||||
try {
|
||||
await window
|
||||
.require('WAWebNewsletterUpdateUserSettingJob')
|
||||
.updateNewsletterUserSetting({
|
||||
newsletterJid: window
|
||||
.require('WAJids')
|
||||
.toNewsletterJid(channelId),
|
||||
type: window.require('WAWebNewsletterModelUtils')
|
||||
.ADMIN_NOTIFICATIONS,
|
||||
muteExpirationValue:
|
||||
action === 'MUTE'
|
||||
? window.require(
|
||||
'WAWebNewsletterModelUtils',
|
||||
).MUTED_STATE
|
||||
: window.require(
|
||||
'WAWebNewsletterModelUtils',
|
||||
).UNMUTED_STATE,
|
||||
});
|
||||
return true;
|
||||
} catch (err) {
|
||||
if (err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
this.id._serialized,
|
||||
action,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +503,7 @@ module.exports = Channel;
|
|||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on January 30, 2026.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on April 24, 2026.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
|
|
|||
Loading…
Reference in a new issue