jagproject 26.3.26 → 26.3.28
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/Defaults/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const libsignal_js_1 = require("../Signal/libsignal.js");
|
|
|
11
11
|
const browser_utils_js_1 = require("../Utils/browser-utils.js");
|
|
12
12
|
const logger_js_1 = __importDefault(require("../Utils/logger.js"));
|
|
13
13
|
const waVer = require('./wileys-version.json');
|
|
14
|
-
exports.version = waVer?.version || [2, 3000,
|
|
14
|
+
exports.version = waVer?.version || [2, 3000, 1036833994];
|
|
15
15
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
16
16
|
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
17
17
|
exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
|
@@ -48,6 +48,65 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
48
48
|
index_js_1.proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
|
|
49
49
|
index_js_1.proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3
|
|
50
50
|
];
|
|
51
|
+
const INTERACTIVE_MESSAGE_KEYS = ['interactiveMessage', 'buttonsMessage', 'listMessage', 'templateMessage'];
|
|
52
|
+
const buildInteractiveMessageContextInfo = (existing) => ({
|
|
53
|
+
...(existing || {}),
|
|
54
|
+
deviceListMetadata: existing?.deviceListMetadata || {},
|
|
55
|
+
deviceListMetadataVersion: existing?.deviceListMetadataVersion || 2
|
|
56
|
+
});
|
|
57
|
+
const wrapInteractiveMessageForLegacyCompatibility = (msg) => {
|
|
58
|
+
if (!msg || typeof msg !== 'object') {
|
|
59
|
+
return msg;
|
|
60
|
+
}
|
|
61
|
+
const topLevelHasInteractive = INTERACTIVE_MESSAGE_KEYS.some(key => !!msg[key]);
|
|
62
|
+
const wrappedViewOnceMessage = msg.viewOnceMessage?.message;
|
|
63
|
+
const wrappedViewOnceV2Message = msg.viewOnceMessageV2?.message;
|
|
64
|
+
const wrappedViewOnceV2ExtMessage = msg.viewOnceMessageV2Extension?.message;
|
|
65
|
+
const wrappedMessage = wrappedViewOnceMessage || wrappedViewOnceV2Message || wrappedViewOnceV2ExtMessage;
|
|
66
|
+
const wrappedHasInteractive = !!(wrappedMessage && INTERACTIVE_MESSAGE_KEYS.some(key => !!wrappedMessage[key]));
|
|
67
|
+
if (wrappedHasInteractive) {
|
|
68
|
+
const patchedWrappedMessage = {
|
|
69
|
+
...wrappedMessage,
|
|
70
|
+
messageContextInfo: buildInteractiveMessageContextInfo(wrappedMessage.messageContextInfo)
|
|
71
|
+
};
|
|
72
|
+
if (wrappedViewOnceMessage) {
|
|
73
|
+
return {
|
|
74
|
+
...msg,
|
|
75
|
+
viewOnceMessage: {
|
|
76
|
+
...msg.viewOnceMessage,
|
|
77
|
+
message: patchedWrappedMessage
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (wrappedViewOnceV2Message) {
|
|
82
|
+
return {
|
|
83
|
+
...msg,
|
|
84
|
+
viewOnceMessageV2: {
|
|
85
|
+
...msg.viewOnceMessageV2,
|
|
86
|
+
message: patchedWrappedMessage
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
...msg,
|
|
92
|
+
viewOnceMessageV2Extension: {
|
|
93
|
+
...msg.viewOnceMessageV2Extension,
|
|
94
|
+
message: patchedWrappedMessage
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (!topLevelHasInteractive) {
|
|
99
|
+
return msg;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
viewOnceMessage: {
|
|
103
|
+
message: {
|
|
104
|
+
...msg,
|
|
105
|
+
messageContextInfo: buildInteractiveMessageContextInfo(msg.messageContextInfo)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
};
|
|
51
110
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
52
111
|
version: exports.version,
|
|
53
112
|
browser: browser_utils_js_1.Browsers.macOS('Chrome'),
|
|
@@ -64,7 +123,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
64
123
|
auth: undefined,
|
|
65
124
|
markOnlineOnConnect: true,
|
|
66
125
|
syncFullHistory: true,
|
|
67
|
-
patchMessageBeforeSending: msg => msg,
|
|
126
|
+
patchMessageBeforeSending: msg => wrapInteractiveMessageForLegacyCompatibility(msg),
|
|
68
127
|
shouldSyncHistoryMessage: ({ syncType }) => {
|
|
69
128
|
return syncType !== index_js_1.proto.HistorySync.HistorySyncType.FULL;
|
|
70
129
|
},
|