@whanext/core 0.19.10 → 0.19.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.19.11
4
+
5
+ - Direct `editedMessage` envelopes are now translated into `messageEdited` events instead of being emitted as ordinary messages.
6
+ - View-once detection now follows multi-device and transparent message wrappers before classifying received media.
7
+ - Added regression coverage for direct edit envelopes and device-sent view-once media.
8
+
3
9
  ## 0.19.10
4
10
 
5
11
  - Fixed restored sessions incorrectly waiting for a pairing challenge after the WhatsApp connection was already open.
package/dist/index.js CHANGED
@@ -2434,7 +2434,8 @@ function isZapoViewOnceContent(input) {
2434
2434
  if (input.viewOnceMessage?.message || input.viewOnceMessageV2?.message || viewOnceV2ExtensionMessage(input)) {
2435
2435
  return true;
2436
2436
  }
2437
- return isZapoViewOnceContent(input.ephemeralMessage?.message);
2437
+ const nested = input.ephemeralMessage?.message ?? input.deviceSentMessage?.message ?? input.documentWithCaptionMessage?.message ?? editedWrapperMessage(input);
2438
+ return nested ? isZapoViewOnceContent(nested) : false;
2438
2439
  }
2439
2440
  function extractQuotedZapoMessage(input) {
2440
2441
  const event = input;
@@ -3117,6 +3118,18 @@ var ZapoProvider = class {
3117
3118
  });
3118
3119
  return;
3119
3120
  }
3121
+ const directEdit = this.#directEditedMessage(event.message);
3122
+ if (directEdit && event.key.id) {
3123
+ this.#enqueueProtocolEvent({
3124
+ ...event,
3125
+ protocolMessage: {
3126
+ type: proto.Message.ProtocolMessage.Type.MESSAGE_EDIT,
3127
+ key: event.key,
3128
+ editedMessage: directEdit
3129
+ }
3130
+ });
3131
+ return;
3132
+ }
3120
3133
  this.#handleMessage(event);
3121
3134
  });
3122
3135
  client.on("message_send", (event) => {
@@ -3268,6 +3281,13 @@ var ZapoProvider = class {
3268
3281
  }
3269
3282
  return value;
3270
3283
  }
3284
+ #directEditedMessage(message) {
3285
+ if (!message) return void 0;
3286
+ const direct = message.editedMessage?.message;
3287
+ if (direct) return direct;
3288
+ const nested = message.ephemeralMessage?.message ?? message.deviceSentMessage?.message;
3289
+ return nested ? this.#directEditedMessage(nested) : void 0;
3290
+ }
3271
3291
  #protocolMessage(event) {
3272
3292
  if (event.protocolMessage) return event.protocolMessage;
3273
3293
  const content = unwrapZapoMessageContent(event.message);