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:
alechkos 2025-05-31 21:36:19 +03:00 • committed by GitHub
commit d0642b761c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -65,7 +65,6 @@ exports.ExposeStore = () => {
window.Store.SendSeen = window.require('WAWebUpdateUnreadChatAction');
window.Store.User = window.require('WAWebUserPrefsMeUser');
window.Store.ContactMethods = window.require('WAWebContactGetters');
window.Store.UploadUtils = window.require('WAWebUploadManager');
window.Store.UserConstructor = window.require('WAWebWid');
window.Store.Validators = window.require('WALinkify');
window.Store.VCard = window.require('WAWebFrontendVcardUtils');
@ -95,22 +94,21 @@ exports.ExposeStore = () => {
window.Store.ReplyUtils = window.require('WAWebMsgReply');
window.Store.BotSecret = window.require('WAWebBotMessageSecret');
window.Store.BotProfiles = window.require('WAWebBotProfileCollection');
window.Store.ContactCollection = window.require('WAWebContactCollection').ContactCollection;
window.Store.DeviceList = window.require('WAWebApiDeviceList');
window.Store.HistorySync = window.require('WAWebSendNonMessageDataRequest');
if (window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.1014111620'))
window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
window.Store.ChatGetters = window.require('WAWebChatGetters');
window.Store.Settings = {
...window.require('WAWebUserPrefsGeneral'),
...window.require('WAWebUserPrefsNotifications'),
setPushname: window.require('WAWebSetPushnameConnAction').setPushname
};
window.Store.NumberInfo = {
...window.require('WAPhoneUtils'),
...window.require('WAPhoneFindCC')
};
window.Store.ForwardUtils = {
...window.require('WAWebForwardMessagesToChat')
};
@ -141,6 +139,37 @@ exports.ExposeStore = () => {
...window.require('WAWebApiMembershipApprovalRequestStore'),
...window.require('WASmaxGroupsMembershipRequestsActionRPC')
};
window.Store.ChannelUtils = {
...window.require('WAWebLoadNewsletterPreviewChatAction'),
...window.require('WAWebNewsletterMetadataQueryJob'),
...window.require('WAWebNewsletterCreateQueryJob'),
...window.require('WAWebEditNewsletterMetadataAction'),
...window.require('WAWebNewsletterDeleteAction'),
...window.require('WAWebNewsletterSubscribeAction'),
...window.require('WAWebNewsletterUnsubscribeAction'),
...window.require('WAWebNewsletterDirectorySearchAction'),
...window.require('WAWebNewsletterToggleMuteStateJob'),
...window.require('WAWebNewsletterGatingUtils'),
...window.require('WAWebNewsletterModelUtils'),
...window.require('WAWebMexAcceptNewsletterAdminInviteJob'),
...window.require('WAWebMexRevokeNewsletterAdminInviteJob'),
...window.require('WAWebChangeNewsletterOwnerAction'),
...window.require('WAWebDemoteNewsletterAdminAction'),
...window.require('WAWebNewsletterDemoteAdminJob'),
countryCodesIso: window.require('WAWebCountriesNativeCountryNames'),
currentRegion: window.require('WAWebL10N').getRegion(),
};
window.Store.SendChannelMessage = {
...window.require('WAWebNewsletterUpdateMsgsRecordsJob'),
...window.require('WAWebMsgDataFromModel'),
...window.require('WAWebNewsletterSendMessageJob'),
...window.require('WAWebNewsletterSendMsgAction'),
...window.require('WAMediaCalculateFilehash')
};
window.Store.ChannelSubscribers = {
...window.require('WAWebMexFetchNewsletterSubscribersJob'),
...window.require('WAWebNewsletterSubscriberListAction')
};
window.Store.AddressbookContactUtils = {
...window.require('WAWebSaveContactAction'),
...window.require('WAWebDeleteContactAction')