@pney/whatsapp-web 1.34.4 → 1.34.6-1

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.
@@ -311,7 +311,7 @@ class Message extends Base {
311
311
  */
312
312
  async reload() {
313
313
  const newData = await this.client.pupPage.evaluate(async (msgId) => {
314
- const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
314
+ const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
315
315
  if (!msg) return null;
316
316
  return window.WWebJS.getMessageModel(msg);
317
317
  }, this.id._serialized);
@@ -356,7 +356,7 @@ class Message extends Base {
356
356
 
357
357
  /**
358
358
  * Returns groups mentioned in this message
359
- * @returns {Promise<GroupChat[]|[]>}
359
+ * @returns {Promise<Array<GroupChat>>}
360
360
  */
361
361
  async getGroupMentions() {
362
362
  return await Promise.all(this.groupMentions.map(async (m) => await this.client.getChatById(m.groupJid._serialized)));
@@ -370,8 +370,8 @@ class Message extends Base {
370
370
  if (!this.hasQuotedMsg) return undefined;
371
371
 
372
372
  const quotedMsg = await this.client.pupPage.evaluate(async (msgId) => {
373
- const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
374
- const quotedMsg = window.Store.QuotedMsg.getQuotedMsgObj(msg);
373
+ const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
374
+ const quotedMsg = window.require('WAWebQuotedMsgModelUtils').getQuotedMsgObj(msg);
375
375
  return window.WWebJS.getMessageModel(quotedMsg);
376
376
  }, this.id._serialized);
377
377
 
@@ -410,9 +410,9 @@ class Message extends Base {
410
410
  await this.client.pupPage.evaluate(async (messageId, reaction) => {
411
411
  if (!messageId) return null;
412
412
  const msg =
413
- window.Store.Msg.get(messageId) || (await window.Store.Msg.getMessagesById([messageId]))?.messages?.[0];
413
+ (window.require('WAWebCollections')).Msg.get(messageId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([messageId]))?.messages?.[0];
414
414
  if(!msg) return null;
415
- await window.Store.sendReactionToMsg(msg, reaction);
415
+ await (window.require('WAWebSendReactionMsgAction'))(msg, reaction);
416
416
  }, this.id._serialized, reaction);
417
417
  }
418
418
 
@@ -448,7 +448,9 @@ class Message extends Base {
448
448
  }
449
449
 
450
450
  const result = await this.client.pupPage.evaluate(async (msgId) => {
451
- const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
451
+ const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
452
+
453
+ // REUPLOADING mediaStage means the media is expired and the download button is spinning, cannot be downloaded now
452
454
  if (!msg || !msg.mediaData || msg.mediaData.mediaStage === 'REUPLOADING') {
453
455
  return null;
454
456
  }
@@ -470,7 +472,7 @@ class Message extends Base {
470
472
  addAnnotations: function() { return this; },
471
473
  addPoint: function() { return this; }
472
474
  };
473
- const decryptedMedia = await window.Store.DownloadManager.downloadAndMaybeDecrypt({
475
+ const decryptedMedia = await (window.require('WAWebDownloadManager').downloadManager).downloadAndMaybeDecrypt({
474
476
  directPath: msg.directPath,
475
477
  encFilehash: msg.encFilehash,
476
478
  filehash: msg.filehash,
@@ -506,21 +508,23 @@ class Message extends Base {
506
508
  */
507
509
  async delete(everyone, clearMedia = true) {
508
510
  await this.client.pupPage.evaluate(async (msgId, everyone, clearMedia) => {
509
- const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
510
- const chat = window.Store.Chat.get(msg.id.remote) || (await window.Store.Chat.find(msg.id.remote));
511
+ const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
512
+ const chat = (window.require('WAWebCollections')).Chat.get(msg.id.remote) || (await (window.require('WAWebCollections')).Chat.find(msg.id.remote));
511
513
 
512
514
  const canRevoke =
513
- window.Store.MsgActionChecks.canSenderRevokeMsg(msg) || window.Store.MsgActionChecks.canAdminRevokeMsg(msg);
515
+ window.require('WAWebMsgActionCapability').canSenderRevokeMsg(msg) || window.require('WAWebMsgActionCapability').canAdminRevokeMsg(msg);
514
516
 
517
+ const { Cmd } = window.require('WAWebCmd');
518
+
515
519
  if (everyone && canRevoke) {
516
- return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
517
- ? window.Store.Cmd.sendRevokeMsgs(chat, { list: [msg], type: 'message' }, { clearMedia: clearMedia })
518
- : window.Store.Cmd.sendRevokeMsgs(chat, [msg], { clearMedia: true, type: msg.id.fromMe ? 'Sender' : 'Admin' });
520
+ return window.WWebJS.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
521
+ ? Cmd.sendRevokeMsgs(chat, { list: [msg], type: 'message' }, { clearMedia: clearMedia })
522
+ : Cmd.sendRevokeMsgs(chat, [msg], { clearMedia: true, type: msg.id.fromMe ? 'Sender' : 'Admin' });
519
523
  }
520
524
 
521
- return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
522
- ? window.Store.Cmd.sendDeleteMsgs(chat, { list: [msg], type: 'message' }, clearMedia)
523
- : window.Store.Cmd.sendDeleteMsgs(chat, [msg], clearMedia);
525
+ return window.WWebJS.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
526
+ ? Cmd.sendDeleteMsgs(chat, { list: [msg], type: 'message' }, clearMedia)
527
+ : Cmd.sendDeleteMsgs(chat, [msg], clearMedia);
524
528
  }, this.id._serialized, everyone, clearMedia);
525
529
  }
526
530
 
@@ -529,10 +533,10 @@ class Message extends Base {
529
533
  */
530
534
  async star() {
531
535
  await this.client.pupPage.evaluate(async (msgId) => {
532
- const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
533
- if (window.Store.MsgActionChecks.canStarMsg(msg)) {
534
- let chat = await window.Store.Chat.find(msg.id.remote);
535
- return window.Store.Cmd.sendStarMsgs(chat, [msg], false);
536
+ const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
537
+ if (window.require('WAWebMsgActionCapability').canStarMsg(msg)) {
538
+ let chat = await (window.require('WAWebCollections')).Chat.find(msg.id.remote);
539
+ return (window.require('WAWebCmd').Cmd).sendStarMsgs(chat, [msg], false);
536
540
  }
537
541
  }, this.id._serialized);
538
542
  }
@@ -542,10 +546,10 @@ class Message extends Base {
542
546
  */
543
547
  async unstar() {
544
548
  await this.client.pupPage.evaluate(async (msgId) => {
545
- const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
546
- if (window.Store.MsgActionChecks.canStarMsg(msg)) {
547
- let chat = await window.Store.Chat.find(msg.id.remote);
548
- return window.Store.Cmd.sendUnstarMsgs(chat, [msg], false);
549
+ const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
550
+ if (window.require('WAWebMsgActionCapability').canStarMsg(msg)) {
551
+ let chat = await (window.require('WAWebCollections')).Chat.find(msg.id.remote);
552
+ return (window.require('WAWebCmd').Cmd).sendUnstarMsgs(chat, [msg], false);
549
553
  }
550
554
  }, this.id._serialized);
551
555
  }
@@ -589,12 +593,12 @@ class Message extends Base {
589
593
  */
590
594
  async getInfo() {
591
595
  const info = await this.client.pupPage.evaluate(async (msgId) => {
592
- const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
596
+ const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
593
597
  if (!msg || !msg.id.fromMe) return null;
594
598
 
595
599
  return new Promise((resolve) => {
596
600
  setTimeout(async () => {
597
- resolve(await window.Store.getMsgInfo(msg.id));
601
+ resolve(await (window.require('WAWebApiMessageInfoStore').queryMsgInfo)(msg.id));
598
602
  }, (Date.now() - msg.t * 1000 < 1250) && Math.floor(Math.random() * (1200 - 1100 + 1)) + 1100 || 0);
599
603
  });
600
604
  }, this.id._serialized);
@@ -623,7 +627,7 @@ class Message extends Base {
623
627
  async getPayment() {
624
628
  if (this.type === MessageTypes.PAYMENT) {
625
629
  const msg = await this.client.pupPage.evaluate(async (msgId) => {
626
- const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
630
+ const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
627
631
  if(!msg) return null;
628
632
  return msg.serialize();
629
633
  }, this.id._serialized);
@@ -652,7 +656,7 @@ class Message extends Base {
652
656
  }
653
657
 
654
658
  const reactions = await this.client.pupPage.evaluate(async (msgId) => {
655
- const msgReactions = await window.Store.Reactions.find(msgId);
659
+ const msgReactions = await (window.require('WAWebCollections')).Reactions.find(msgId);
656
660
  if (!msgReactions || !msgReactions.reactions.length) return null;
657
661
  return msgReactions.reactions.serialize();
658
662
  }, this.id._serialized);
@@ -698,10 +702,10 @@ class Message extends Base {
698
702
  return null;
699
703
  }
700
704
  const messageEdit = await this.client.pupPage.evaluate(async (msgId, message, options) => {
701
- const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
705
+ const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
702
706
  if (!msg) return null;
703
707
 
704
- let canEdit = window.Store.MsgActionChecks.canEditText(msg) || window.Store.MsgActionChecks.canEditCaption(msg);
708
+ let canEdit = window.require('WAWebMsgActionCapability').canEditText(msg) || window.require('WAWebMsgActionCapability').canEditCaption(msg);
705
709
  if (canEdit) {
706
710
  const msgEdit = await window.WWebJS.editMessage(msg, message, options);
707
711
  return msgEdit.serialize();
@@ -726,7 +730,7 @@ class Message extends Base {
726
730
  }
727
731
 
728
732
  const edittedEventMsg = await this.client.pupPage.evaluate(async (msgId, editedEventObject) => {
729
- const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
733
+ const msg = (window.require('WAWebCollections')).Msg.get(msgId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([msgId]))?.messages?.[0];
730
734
  if (!msg) return null;
731
735
 
732
736
  const { name, startTimeTs, eventSendOptions } = editedEventObject;
@@ -740,8 +744,8 @@ class Message extends Base {
740
744
  isEventCanceled: eventSendOptions.isEventCanceled,
741
745
  };
742
746
 
743
- await window.Store.ScheduledEventMsgUtils.sendEventEditMessage(eventOptions, msg);
744
- const editedMsg = window.Store.Msg.get(msg.id._serialized);
747
+ await (window.require('WAWebSendEventEditMsgAction')).sendEventEditMessage(eventOptions, msg);
748
+ const editedMsg = (window.require('WAWebCollections')).Msg.get(msg.id._serialized);
745
749
  return editedMsg?.serialize();
746
750
  }, this.id._serialized, editedEventObject);
747
751
 
@@ -768,7 +772,7 @@ class Message extends Base {
768
772
  if (!Array.isArray(votes)) votes = [votes];
769
773
  let localIdSet = new Set();
770
774
  const msg =
771
- window.Store.Msg.get(messageId) || (await window.Store.Msg.getMessagesById([messageId]))?.messages?.[0];
775
+ (window.require('WAWebCollections')).Msg.get(messageId) || (await (window.require('WAWebCollections')).Msg.getMessagesById([messageId]))?.messages?.[0];
772
776
  if (!msg) return null;
773
777
 
774
778
  msg.pollOptions.forEach(a => {
@@ -777,7 +781,7 @@ class Message extends Base {
777
781
  }
778
782
  });
779
783
 
780
- await window.Store.PollsSendVote.sendVote(msg, localIdSet);
784
+ await (window.require('WAWebPollsSendVoteMsgAction')).sendVote(msg, localIdSet);
781
785
  }, this.id._serialized, selectedOptions);
782
786
  }
783
787
  }