feat: Channel (#2620)
* window.injectToFunction clarifications * added createChannel method * initial Channel class structure * added getChannelById and getChannels methods * added 4 methods to change channel metadata * added deleteChannel method * added subscribe to/unsubscribe from channel methods * ecmaVersion updated to 2022 * added searchChannels method * refactoring of: getChat, getChannel, getChatModel, getChannelModel * removed Channel.canSend * sendMessage updated to support channels [p1] * createChannel: returns string if an error occupied * added getSubscribers * added mute/unmute methods * searchChannels: minor update * sendMessage updated to support channels [p2] - added support to send image, sticker, gif and video * [REFAC] refactored chat retrieving in getChatOrChannel * [FEAT] added getChannelByInviteCode method * [CHG] added check if channel creation enabled * [FEAT] added sendChannelAdminInvitation method * [WIP] preparations for sending polls [p1] * [BUG] fixed some internal functions * [BUG] fixed poll creation * [COPY] renamed some internal functions - window.WWebJS.getChatOrChannel renamed back to window.WWebJS.getChat -window.WWebJS.getChatOrChannelModel renamed back to window.WWebJS.getChatModel * fix: typo * fix: send docs without caption * fix: fixed some internal function * fix: channel retrieving * fix: fixed internal getChannelMetadata function * fix: fixed channel admin can unsubscribe from channel * feat: channel admin functionality * feat: added fetchMessages method Co-authored-by: tuke307 <58882912+tuke307@users.noreply.github.com> * refactor: revert removing support for Buttons and Lists Note: buttons and lists are deprecated * refactor: revert parameter name from 'chatOrChannel' to 'chat' * fix: support Node v12 * refactor: return 'undefined' in a case of falsy value * refactor: use already created variable * docs: fix 'countryCodes' property type * fix: 'searchChannels' method fixed * fix: add check in 'setReactionSetting' method * sendNewsletterMessageJob requires a proper Msg Object in 2.24xx (#10) Co-authored-by: Sven Neumann <s.neumann@websix.de> * style: fix broken link in readme file * fix: only directPath determines whether hasMedia or not fixes #2952 * fix: get rid of unnecessary 'await' * feat: add option to send polls in channels * refactor: get channel instances with 'getChatById' * chore: fix eslint * fix: fatal error * refactor: delete local models by default when unsubscribing * fix: prevent TypeError if no channel models are returned * fix: update 'searchChannels' function for WWeb > 2.3000.0 * fix: fix for 'getChannelByInviteCode' function * fix: fix for 'sendChannelAdminInvite' function * fix: update 'fetchMessages' for channels * refactor: update 'setReactionSetting' function * fix: update 'sendMessage' for channels * feat: add 'transferChannelOwnership' function * refactor: add 'deleteChannel' function to 'Client' * style: fix project code style * chore: eslint fix * feat: add 'sendSeen' function * fix: fix the function restoration after injection * refactor: remove duplicate module * fix: get isNewsletter properly * fix: fix channels media - add mediaHandle Co-authored-by: devlikepro <155617407+devlikepro@users.noreply.github.com> --------- Co-authored-by: tuke307 <58882912+tuke307@users.noreply.github.com> Co-authored-by: Sven <sven2neumann@gmail.com> Co-authored-by: Sven Neumann <s.neumann@websix.de> Co-authored-by: devlikepro <155617407+devlikepro@users.noreply.github.com>
This commit is contained in:
parent
dd257b2039
commit
d0642b761c
13 changed files with 1241 additions and 234 deletions
|
|
@ -191,8 +191,7 @@ class GroupChat extends Chat {
|
|||
*/
|
||||
async removeParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
|
||||
const participants = participantIds.map(p => {
|
||||
return chat.groupMetadata.participants.get(p);
|
||||
}).filter(p => Boolean(p));
|
||||
|
|
@ -208,8 +207,7 @@ class GroupChat extends Chat {
|
|||
*/
|
||||
async promoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
|
||||
const participants = participantIds.map(p => {
|
||||
return chat.groupMetadata.participants.get(p);
|
||||
}).filter(p => Boolean(p));
|
||||
|
|
@ -225,8 +223,7 @@ class GroupChat extends Chat {
|
|||
*/
|
||||
async demoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
|
||||
const participants = participantIds.map(p => {
|
||||
return chat.groupMetadata.participants.get(p);
|
||||
}).filter(p => Boolean(p));
|
||||
|
|
@ -466,8 +463,7 @@ class GroupChat extends Chat {
|
|||
*/
|
||||
async leave() {
|
||||
await this.client.pupPage.evaluate(async chatId => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
|
||||
return window.Store.GroupUtils.sendExitGroup(chat);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue