@zetagoaurum-socket/wasocket 2.1.7 → 2.1.8
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/lib/Socket/messages-send.js +22 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeMessagesSocket = void 0;
|
|
7
7
|
const boom_1 = require("@hapi/boom");
|
|
8
|
+
const crypto = require("crypto"); // Added for supportPayload messageSecret
|
|
8
9
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
9
10
|
const WAProto_1 = require("../../WAProto");
|
|
10
11
|
const Defaults_1 = require("../Defaults");
|
|
@@ -319,6 +320,25 @@ const makeMessagesSocket = (config) => {
|
|
|
319
320
|
};
|
|
320
321
|
const extraAttrs = {}
|
|
321
322
|
const messages = Utils_1.normalizeMessageContent(message)
|
|
323
|
+
|
|
324
|
+
// [AI BADGE FIX v2.1.8] Inject supportPayload into content instead of using risky transport node
|
|
325
|
+
if (AI) {
|
|
326
|
+
const msgType = Object.keys(messages)[0];
|
|
327
|
+
if (msgType) {
|
|
328
|
+
// Ensure contextInfo exists
|
|
329
|
+
messages[msgType].contextInfo = messages[msgType].contextInfo || {};
|
|
330
|
+
|
|
331
|
+
// Inject AI metadata
|
|
332
|
+
messages[msgType].contextInfo.messageSecret = messages[msgType].contextInfo.messageSecret || crypto.randomBytes(32);
|
|
333
|
+
messages[msgType].contextInfo.supportPayload = JSON.stringify({
|
|
334
|
+
version: 1,
|
|
335
|
+
is_ai_message: true,
|
|
336
|
+
should_show_system_message: true,
|
|
337
|
+
ticket_id: crypto.randomBytes(16).toString('hex')
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
322
342
|
const buttonType = getButtonType(messages);
|
|
323
343
|
if (participant) {
|
|
324
344
|
// when the retry request is not for a group
|
|
@@ -546,6 +566,7 @@ const makeMessagesSocket = (config) => {
|
|
|
546
566
|
logger.debug({ jid }, 'adding device identity');
|
|
547
567
|
}
|
|
548
568
|
|
|
569
|
+
/* [REMOVED IN v2.1.8] Risky transport node causes message drops
|
|
549
570
|
if (AI) {
|
|
550
571
|
const botNode = {
|
|
551
572
|
tag: 'bot',
|
|
@@ -565,6 +586,7 @@ const makeMessagesSocket = (config) => {
|
|
|
565
586
|
stanza.content.push(botNode)
|
|
566
587
|
}
|
|
567
588
|
}
|
|
589
|
+
*/
|
|
568
590
|
|
|
569
591
|
if(!isNewsletter && buttonType && !isStatus) {
|
|
570
592
|
const content = WABinary_1.getAdditionalNode(buttonType)
|