whatsapp-web.js 1.30.1-alpha.2 → 1.30.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -128,9 +128,9 @@ For further details on saving and restoring sessions, explore the provided [Auth
128
128
  | Set user status message | ✅ |
129
129
  | React to messages | ✅ |
130
130
  | Create polls | ✅ |
131
+ | Channels | ✅ |
131
132
  | Vote in polls | 🔜 |
132
133
  | Communities | 🔜 |
133
- | Channels | 🔜 |
134
134
 
135
135
  Something missing? Make an issue and let us know!
136
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whatsapp-web.js",
3
- "version": "1.30.1-alpha.2",
3
+ "version": "1.30.1-alpha.3",
4
4
  "description": "Library for interacting with the WhatsApp Web API ",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -98,6 +98,7 @@ exports.ExposeStore = () => {
98
98
  window.Store.HistorySync = window.require('WAWebSendNonMessageDataRequest');
99
99
  window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
100
100
  window.Store.ChatGetters = window.require('WAWebChatGetters');
101
+ window.Store.UploadUtils = window.require('WAWebUploadManager');
101
102
 
102
103
  window.Store.Settings = {
103
104
  ...window.require('WAWebUserPrefsGeneral'),
@@ -28,8 +28,9 @@ exports.LoadUtils = () => {
28
28
 
29
29
  let mediaOptions = {};
30
30
  if (options.media) {
31
- mediaOptions = await window.WWebJS.processMediaData(
32
- options.media, {
31
+ mediaOptions = options.sendMediaAsSticker && !isChannel
32
+ ? await window.WWebJS.processStickerData(options.media)
33
+ : await window.WWebJS.processMediaData(options.media, {
33
34
  forceSticker: options.sendMediaAsSticker,
34
35
  forceGif: options.sendVideoAsGif,
35
36
  forceVoice: options.sendAudioAsVoice,
@@ -362,6 +363,34 @@ exports.LoadUtils = () => {
362
363
  };
363
364
  };
364
365
 
366
+ window.WWebJS.processStickerData = async (mediaInfo) => {
367
+ if (mediaInfo.mimetype !== 'image/webp') throw new Error('Invalid media type');
368
+
369
+ const file = window.WWebJS.mediaInfoToFile(mediaInfo);
370
+ let filehash = await window.WWebJS.getFileHash(file);
371
+ let mediaKey = await window.WWebJS.generateHash(32);
372
+
373
+ const controller = new AbortController();
374
+ const uploadedInfo = await window.Store.UploadUtils.encryptAndUpload({
375
+ blob: file,
376
+ type: 'sticker',
377
+ signal: controller.signal,
378
+ mediaKey
379
+ });
380
+
381
+ const stickerInfo = {
382
+ ...uploadedInfo,
383
+ clientUrl: uploadedInfo.url,
384
+ deprecatedMms3Url: uploadedInfo.url,
385
+ uploadhash: uploadedInfo.encFilehash,
386
+ size: file.size,
387
+ type: 'sticker',
388
+ filehash
389
+ };
390
+
391
+ return stickerInfo;
392
+ };
393
+
365
394
  window.WWebJS.processMediaData = async (mediaInfo, { forceSticker, forceGif, forceVoice, forceDocument, forceMediaHd, sendToChannel }) => {
366
395
  const file = window.WWebJS.mediaInfoToFile(mediaInfo);
367
396
  const opaqueData = await window.Store.OpaqueData.createFromData(file, file.type);