alwaysaqioo 1.1.1 → 1.1.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 +9 -110
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +3344 -0
- package/WAProto/index.d.ts +37016 -0
- package/WAProto/index.js +79296 -118676
- package/WASignalGroup/GroupProtocol.js +1697 -0
- package/WASignalGroup/ciphertext_message.js +16 -0
- package/WASignalGroup/group_cipher.js +120 -0
- package/WASignalGroup/group_session_builder.js +46 -0
- package/WASignalGroup/index.js +5 -0
- package/WASignalGroup/keyhelper.js +21 -0
- package/WASignalGroup/protobufs.js +3 -0
- package/WASignalGroup/queue_job.js +69 -0
- package/WASignalGroup/sender_chain_key.js +50 -0
- package/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/WASignalGroup/sender_key_message.js +92 -0
- package/WASignalGroup/sender_key_name.js +70 -0
- package/WASignalGroup/sender_key_record.js +56 -0
- package/WASignalGroup/sender_key_state.js +129 -0
- package/WASignalGroup/sender_message_key.js +39 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +2 -19
- package/lib/Signal/Group/x +1 -0
- package/lib/Socket/chats.d.ts +32 -215
- package/lib/Socket/chats.js +75 -155
- package/lib/Socket/groups.js +18 -18
- package/lib/Socket/index.js +0 -1
- package/lib/Socket/messages-send.d.ts +2 -2
- package/lib/Socket/messages-send.js +348 -327
- package/lib/Socket/newsletter.js +21 -100
- package/lib/Socket/socket.js +30 -65
- package/lib/Types/Newsletter.d.ts +86 -97
- package/lib/Types/Newsletter.js +32 -38
- package/lib/Utils/generics.js +33 -65
- package/lib/Utils/messages-media.js +57 -145
- package/lib/Utils/messages.js +14 -26
- package/lib/Utils/signal.js +46 -48
- package/lib/Utils/use-multi-file-auth-state.js +6 -45
- package/lib/Utils/validate-connection.js +65 -89
- package/lib/WABinary/constants.d.ts +24 -27
- package/lib/WABinary/encode.js +123 -160
- package/lib/WABinary/generic-utils.d.ts +1 -2
- package/lib/WABinary/generic-utils.js +43 -123
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +2 -12
- package/package.json +98 -100
- package/engine-requirements.js +0 -10
- package/lib/Socket/luxu.d.ts +0 -268
- package/lib/Socket/luxu.js +0 -591
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
@@ -8,14 +8,10 @@ const boom_1 = require("@hapi/boom");
|
|
|
8
8
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
9
9
|
const WAProto_1 = require("../../WAProto");
|
|
10
10
|
const Defaults_1 = require("../Defaults");
|
|
11
|
-
const axios_1 = require("axios")
|
|
12
|
-
const Types_1 = require("../Types")
|
|
13
11
|
const Utils_1 = require("../Utils");
|
|
14
12
|
const link_preview_1 = require("../Utils/link-preview");
|
|
15
13
|
const WABinary_1 = require("../WABinary");
|
|
16
14
|
const newsletter_1 = require("./newsletter");
|
|
17
|
-
const WAUSync_1 = require("../WAUSync")
|
|
18
|
-
const imup = require('./luxu');
|
|
19
15
|
var ListType = WAProto_1.proto.Message.ListMessage.ListType;
|
|
20
16
|
const makeMessagesSocket = (config) => {
|
|
21
17
|
const {
|
|
@@ -37,8 +33,7 @@ const makeMessagesSocket = (config) => {
|
|
|
37
33
|
generateMessageTag,
|
|
38
34
|
sendNode,
|
|
39
35
|
groupMetadata,
|
|
40
|
-
groupToggleEphemeral
|
|
41
|
-
executeUSyncQuery
|
|
36
|
+
groupToggleEphemeral
|
|
42
37
|
} = sock;
|
|
43
38
|
const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
|
|
44
39
|
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES,
|
|
@@ -58,9 +53,9 @@ const makeMessagesSocket = (config) => {
|
|
|
58
53
|
},
|
|
59
54
|
content: [{ tag: 'media_conn', attrs: {} }]
|
|
60
55
|
});
|
|
61
|
-
const mediaConnNode = WABinary_1.getBinaryNodeChild(result, 'media_conn');
|
|
56
|
+
const mediaConnNode = (0, WABinary_1.getBinaryNodeChild)(result, 'media_conn');
|
|
62
57
|
const node = {
|
|
63
|
-
hosts: WABinary_1.getBinaryNodeChildren(mediaConnNode, 'host').map(({ attrs }) => ({
|
|
58
|
+
hosts: (0, WABinary_1.getBinaryNodeChildren)(mediaConnNode, 'host').map(({ attrs }) => ({
|
|
64
59
|
hostname: attrs.hostname,
|
|
65
60
|
maxContentLengthBytes: +attrs.maxContentLengthBytes,
|
|
66
61
|
})),
|
|
@@ -89,7 +84,7 @@ const makeMessagesSocket = (config) => {
|
|
|
89
84
|
if (isReadReceipt) {
|
|
90
85
|
node.attrs.t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
91
86
|
}
|
|
92
|
-
if (type === 'sender' && WABinary_1.isJidUser(jid)) {
|
|
87
|
+
if (type === 'sender' && (0, WABinary_1.isJidUser)(jid)) {
|
|
93
88
|
node.attrs.recipient = jid;
|
|
94
89
|
node.attrs.to = participant;
|
|
95
90
|
}
|
|
@@ -100,7 +95,7 @@ const makeMessagesSocket = (config) => {
|
|
|
100
95
|
}
|
|
101
96
|
}
|
|
102
97
|
if (type) {
|
|
103
|
-
node.attrs.type = WABinary_1.isJidNewsLetter(jid) ? 'read-self' : type;
|
|
98
|
+
node.attrs.type = (0, WABinary_1.isJidNewsLetter)(jid) ? 'read-self' : type;
|
|
104
99
|
}
|
|
105
100
|
const remainingMessageIds = messageIds.slice(1);
|
|
106
101
|
if (remainingMessageIds.length) {
|
|
@@ -134,70 +129,74 @@ const makeMessagesSocket = (config) => {
|
|
|
134
129
|
};
|
|
135
130
|
/** Fetch all the devices we've to send a message to */
|
|
136
131
|
const getUSyncDevices = async (jids, useCache, ignoreZeroDevices) => {
|
|
137
|
-
|
|
138
|
-
|
|
132
|
+
var _a;
|
|
133
|
+
const deviceResults = [];
|
|
139
134
|
if (!useCache) {
|
|
140
|
-
logger.debug('not using cache for devices')
|
|
135
|
+
logger.debug('not using cache for devices');
|
|
141
136
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
jids = Array.from(new Set(jids))
|
|
146
|
-
|
|
137
|
+
const users = [];
|
|
138
|
+
jids = Array.from(new Set(jids));
|
|
147
139
|
for (let jid of jids) {
|
|
148
|
-
const user = WABinary_1.jidDecode(jid)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (devices) {
|
|
156
|
-
deviceResults.push(...devices)
|
|
157
|
-
logger.trace({ user }, 'using cache for devices')
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
else {
|
|
161
|
-
toFetch.push(jid)
|
|
162
|
-
}
|
|
140
|
+
const user = (_a = (0, WABinary_1.jidDecode)(jid)) === null || _a === void 0 ? void 0 : _a.user;
|
|
141
|
+
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
142
|
+
const devices = userDevicesCache.get(user);
|
|
143
|
+
if (devices && useCache) {
|
|
144
|
+
deviceResults.push(...devices);
|
|
145
|
+
logger.trace({ user }, 'using cache for devices');
|
|
163
146
|
}
|
|
164
|
-
|
|
165
147
|
else {
|
|
166
|
-
|
|
148
|
+
users.push({ tag: 'user', attrs: { jid } });
|
|
167
149
|
}
|
|
168
150
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return deviceResults
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const query = new WAUSync_1.USyncQuery()
|
|
175
|
-
.withContext('message')
|
|
176
|
-
.withDeviceProtocol()
|
|
177
|
-
|
|
178
|
-
for (const jid of toFetch) {
|
|
179
|
-
query.withUser(new WAUSync_1.USyncUser().withId(jid))
|
|
151
|
+
if (!users.length) {
|
|
152
|
+
return deviceResults;
|
|
180
153
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
154
|
+
const iq = {
|
|
155
|
+
tag: 'iq',
|
|
156
|
+
attrs: {
|
|
157
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
158
|
+
type: 'get',
|
|
159
|
+
xmlns: 'usync',
|
|
160
|
+
},
|
|
161
|
+
content: [
|
|
162
|
+
{
|
|
163
|
+
tag: 'usync',
|
|
164
|
+
attrs: {
|
|
165
|
+
sid: generateMessageTag(),
|
|
166
|
+
mode: 'query',
|
|
167
|
+
last: 'true',
|
|
168
|
+
index: '0',
|
|
169
|
+
context: 'message',
|
|
170
|
+
},
|
|
171
|
+
content: [
|
|
172
|
+
{
|
|
173
|
+
tag: 'query',
|
|
174
|
+
attrs: {},
|
|
175
|
+
content: [
|
|
176
|
+
{
|
|
177
|
+
tag: 'devices',
|
|
178
|
+
attrs: { version: '2' }
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
{ tag: 'list', attrs: {}, content: users }
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
};
|
|
187
|
+
const result = await query(iq);
|
|
188
|
+
const extracted = (0, Utils_1.extractDeviceJids)(result, authState.creds.me.id, ignoreZeroDevices);
|
|
189
|
+
const deviceMap = {};
|
|
190
|
+
for (const item of extracted) {
|
|
191
|
+
deviceMap[item.user] = deviceMap[item.user] || [];
|
|
192
|
+
deviceMap[item.user].push(item);
|
|
193
|
+
deviceResults.push(item);
|
|
194
|
+
}
|
|
195
|
+
for (const key in deviceMap) {
|
|
196
|
+
userDevicesCache.set(key, deviceMap[key]);
|
|
197
|
+
}
|
|
198
|
+
return deviceResults;
|
|
199
|
+
};
|
|
201
200
|
const assertSessions = async (jids, force) => {
|
|
202
201
|
let didFetchNewSession = false;
|
|
203
202
|
let jidsRequiringFetch = [];
|
|
@@ -241,29 +240,6 @@ const makeMessagesSocket = (config) => {
|
|
|
241
240
|
}
|
|
242
241
|
return didFetchNewSession;
|
|
243
242
|
};
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const sendPeerDataOperationMessage = async (pdoMessage) => {
|
|
247
|
-
if (!authState.creds.me?.id) {
|
|
248
|
-
throw new boom_1.Boom('Not authenticated')
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const protocolMessage = {
|
|
252
|
-
protocolMessage: {
|
|
253
|
-
peerDataOperationRequestMessage: pdoMessage,
|
|
254
|
-
type: WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
const meJid = WABinary_1.jidNormalizedUser(authState.creds.me.id);
|
|
258
|
-
const msgId = await relayMessage(meJid, protocolMessage, {
|
|
259
|
-
additionalAttributes: {
|
|
260
|
-
category: 'peer',
|
|
261
|
-
// eslint-disable-next-line camelcase
|
|
262
|
-
push_priority: 'high_force',
|
|
263
|
-
},
|
|
264
|
-
});
|
|
265
|
-
return msgId;
|
|
266
|
-
};
|
|
267
243
|
const createParticipantNodes = async (jids, message, extraAttrs) => {
|
|
268
244
|
const patched = await patchMessageBeforeSending(message, jids);
|
|
269
245
|
const bytes = (0, Utils_1.encodeWAMessage)(patched);
|
|
@@ -291,11 +267,11 @@ const makeMessagesSocket = (config) => {
|
|
|
291
267
|
}));
|
|
292
268
|
return { nodes, shouldIncludeDeviceIdentity };
|
|
293
269
|
}; //apela
|
|
294
|
-
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata,
|
|
270
|
+
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList, AI = true }) => {
|
|
295
271
|
const meId = authState.creds.me.id;
|
|
296
272
|
let shouldIncludeDeviceIdentity = false;
|
|
297
273
|
let didPushAdditional = false
|
|
298
|
-
const { user, server } = WABinary_1.jidDecode(jid);
|
|
274
|
+
const { user, server } = (0, WABinary_1.jidDecode)(jid);
|
|
299
275
|
const statusJid = 'status@broadcast';
|
|
300
276
|
const isGroup = server === 'g.us';
|
|
301
277
|
const isStatus = jid === statusJid;
|
|
@@ -304,9 +280,8 @@ const makeMessagesSocket = (config) => {
|
|
|
304
280
|
const isNewsletter = server === 'newsletter';
|
|
305
281
|
msgId = msgId || (0, Utils_1.generateMessageID)();
|
|
306
282
|
useUserDevicesCache = useUserDevicesCache !== false;
|
|
307
|
-
useCachedGroupMetadata = useCachedGroupMetadata !== false && !isStatus
|
|
308
283
|
const participants = [];
|
|
309
|
-
const destinationJid = (!isStatus) ? WABinary_1.jidEncode(user, isLid ? 'lid' : isGroup ? 'g.us' : isNewsletter ? 'newsletter' : 's.whatsapp.net') : statusJid;
|
|
284
|
+
const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' : isNewsletter ? 'newsletter' : 's.whatsapp.net') : statusJid;
|
|
310
285
|
const binaryNodeContent = [];
|
|
311
286
|
const devices = [];
|
|
312
287
|
const meMsg = {
|
|
@@ -315,9 +290,6 @@ const makeMessagesSocket = (config) => {
|
|
|
315
290
|
message
|
|
316
291
|
}
|
|
317
292
|
};
|
|
318
|
-
const extraAttrs = {}
|
|
319
|
-
const messages = Utils_1.normalizeMessageContent(message)
|
|
320
|
-
const buttonType = getButtonType(messages);
|
|
321
293
|
if (participant) {
|
|
322
294
|
// when the retry request is not for a group
|
|
323
295
|
// only send to the specific device that asked for a retry
|
|
@@ -325,80 +297,51 @@ const makeMessagesSocket = (config) => {
|
|
|
325
297
|
if (!isGroup && !isStatus) {
|
|
326
298
|
additionalAttributes = { ...additionalAttributes, 'device_fanout': 'false' };
|
|
327
299
|
}
|
|
328
|
-
const { user, device } = WABinary_1.jidDecode(participant.jid);
|
|
300
|
+
const { user, device } = (0, WABinary_1.jidDecode)(participant.jid);
|
|
329
301
|
devices.push({ user, device });
|
|
330
302
|
}
|
|
331
303
|
await authState.keys.transaction(async () => {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (mediaType) {
|
|
335
|
-
extraAttrs['mediatype'] = mediaType
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (messages.pinInChatMessage || messages.keepInChatMessage || message.reactionMessage || message.protocolMessage?.editedMessage) {
|
|
339
|
-
extraAttrs['decrypt-fail'] = 'hide'
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if (messages.interactiveResponseMessage?.nativeFlowResponseMessage) {
|
|
343
|
-
extraAttrs['native_flow_name'] = messages.interactiveResponseMessage?.nativeFlowResponseMessage.name
|
|
344
|
-
}
|
|
345
|
-
|
|
304
|
+
var _a, _b, _c, _d, _e, _f;
|
|
305
|
+
const mediaType = getMediaType(message);
|
|
346
306
|
if (isGroup || isStatus) {
|
|
347
307
|
const [groupData, senderKeyMap] = await Promise.all([
|
|
348
308
|
(async () => {
|
|
349
|
-
let groupData =
|
|
309
|
+
let groupData = cachedGroupMetadata ? await cachedGroupMetadata(jid) : undefined;
|
|
350
310
|
if (groupData) {
|
|
351
311
|
logger.trace({ jid, participants: groupData.participants.length }, 'using cached group metadata');
|
|
352
312
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
groupData = await groupMetadata(jid)
|
|
313
|
+
if (!groupData && !isStatus) {
|
|
314
|
+
groupData = await groupMetadata(jid);
|
|
356
315
|
}
|
|
357
|
-
|
|
358
316
|
return groupData;
|
|
359
317
|
})(),
|
|
360
318
|
(async () => {
|
|
361
319
|
if (!participant && !isStatus) {
|
|
362
|
-
const result = await authState.keys.get('sender-key-memory', [jid])
|
|
363
|
-
return result[jid] || {}
|
|
320
|
+
const result = await authState.keys.get('sender-key-memory', [jid]);
|
|
321
|
+
return result[jid] || {};
|
|
364
322
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
})()
|
|
323
|
+
return {};
|
|
324
|
+
})()
|
|
369
325
|
]);
|
|
370
326
|
if (!participant) {
|
|
371
|
-
const participantsList = (groupData && !isStatus) ? groupData.participants.map(p => p.id) : []
|
|
372
|
-
|
|
327
|
+
const participantsList = (groupData && !isStatus) ? groupData.participants.map(p => p.id) : [];
|
|
373
328
|
if (isStatus && statusJidList) {
|
|
374
|
-
participantsList.push(...statusJidList)
|
|
329
|
+
participantsList.push(...statusJidList);
|
|
375
330
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
// const expiration = await getEphemeralGroup(jid)
|
|
379
|
-
// additionalAttributes = {
|
|
380
|
-
// ...additionalAttributes,
|
|
381
|
-
// addressing_mode: 'pn',
|
|
382
|
-
// ...expiration ? { expiration: expiration.toString() } : null
|
|
383
|
-
// }
|
|
384
|
-
// }
|
|
385
|
-
|
|
386
|
-
const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false)
|
|
387
|
-
devices.push(...additionalDevices)
|
|
331
|
+
const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false);
|
|
332
|
+
devices.push(...additionalDevices);
|
|
388
333
|
}
|
|
389
|
-
|
|
390
|
-
const
|
|
391
|
-
const bytes = Utils_1.encodeWAMessage(patched);
|
|
392
|
-
|
|
334
|
+
const patched = await patchMessageBeforeSending(message, devices.map(d => (0, WABinary_1.jidEncode)(d.user, isLid ? 'lid' : 's.whatsapp.net', d.device)));
|
|
335
|
+
const bytes = (0, Utils_1.encodeWAMessage)(patched);
|
|
393
336
|
const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({
|
|
394
337
|
group: destinationJid,
|
|
395
338
|
data: bytes,
|
|
396
339
|
meId,
|
|
397
340
|
});
|
|
398
341
|
const senderKeyJids = [];
|
|
399
|
-
|
|
342
|
+
// ensure a connection is established with every device
|
|
400
343
|
for (const { user, device } of devices) {
|
|
401
|
-
const jid = WABinary_1.jidEncode(user, (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) === 'lid' ? 'lid' : 's.whatsapp.net', device);
|
|
344
|
+
const jid = (0, WABinary_1.jidEncode)(user, (groupData === null || groupData === void 0 ? void 0 : groupData.addressingMode) === 'lid' ? 'lid' : 's.whatsapp.net', device);
|
|
402
345
|
if (!senderKeyMap[jid] || !!participant) {
|
|
403
346
|
senderKeyJids.push(jid);
|
|
404
347
|
// store that this person has had the sender keys sent to them
|
|
@@ -416,115 +359,95 @@ const makeMessagesSocket = (config) => {
|
|
|
416
359
|
}
|
|
417
360
|
};
|
|
418
361
|
await assertSessions(senderKeyJids, false);
|
|
419
|
-
const result = await createParticipantNodes(senderKeyJids, senderKeyMsg,
|
|
362
|
+
const result = await createParticipantNodes(senderKeyJids, senderKeyMsg, mediaType ? { mediatype: mediaType } : undefined);
|
|
420
363
|
shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || result.shouldIncludeDeviceIdentity;
|
|
421
364
|
participants.push(...result.nodes);
|
|
422
365
|
}
|
|
423
366
|
binaryNodeContent.push({
|
|
424
367
|
tag: 'enc',
|
|
425
|
-
attrs: { v: '2', type: 'skmsg'
|
|
368
|
+
attrs: { v: '2', type: 'skmsg' },
|
|
426
369
|
content: ciphertext
|
|
427
370
|
});
|
|
428
371
|
await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
|
|
429
372
|
}
|
|
430
373
|
else if (isNewsletter) {
|
|
431
374
|
// Message edit
|
|
432
|
-
if (message.protocolMessage
|
|
433
|
-
msgId = message.protocolMessage.key
|
|
434
|
-
message = message.protocolMessage.editedMessage
|
|
375
|
+
if ((_a = message.protocolMessage) === null || _a === void 0 ? void 0 : _a.editedMessage) {
|
|
376
|
+
msgId = (_b = message.protocolMessage.key) === null || _b === void 0 ? void 0 : _b.id;
|
|
377
|
+
message = message.protocolMessage.editedMessage;
|
|
435
378
|
}
|
|
436
|
-
|
|
437
379
|
// Message delete
|
|
438
|
-
if (message.protocolMessage
|
|
439
|
-
msgId = message.protocolMessage.key
|
|
440
|
-
message = {}
|
|
380
|
+
if (((_c = message.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE) {
|
|
381
|
+
msgId = (_d = message.protocolMessage.key) === null || _d === void 0 ? void 0 : _d.id;
|
|
382
|
+
message = {};
|
|
441
383
|
}
|
|
442
|
-
|
|
443
|
-
const
|
|
444
|
-
const bytes = Utils_1.encodeNewsletterMessage(patched)
|
|
445
|
-
|
|
384
|
+
const patched = await patchMessageBeforeSending(message, []);
|
|
385
|
+
const bytes = WAProto_1.proto.Message.encode(patched).finish();
|
|
446
386
|
binaryNodeContent.push({
|
|
447
387
|
tag: 'plaintext',
|
|
448
|
-
attrs:
|
|
388
|
+
attrs: mediaType ? { mediatype: mediaType } : {},
|
|
449
389
|
content: bytes
|
|
450
|
-
})
|
|
390
|
+
});
|
|
451
391
|
}
|
|
452
392
|
else {
|
|
453
|
-
const { user: meUser } = WABinary_1.jidDecode(meId);
|
|
393
|
+
const { user: meUser, device: meDevice } = (0, WABinary_1.jidDecode)(meId);
|
|
454
394
|
if (!participant) {
|
|
455
|
-
devices.push({ user })
|
|
456
|
-
if
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
if (additionalAttributes?.['category'] !== 'peer') {
|
|
461
|
-
const additionalDevices = await getUSyncDevices([meId, jid], !!useUserDevicesCache, true)
|
|
462
|
-
|
|
463
|
-
devices.push(...additionalDevices)
|
|
395
|
+
devices.push({ user });
|
|
396
|
+
// do not send message to self if the device is 0 (mobile)
|
|
397
|
+
if (meDevice !== undefined && meDevice !== 0) {
|
|
398
|
+
devices.push({ user: meUser });
|
|
464
399
|
}
|
|
400
|
+
const additionalDevices = await getUSyncDevices([meId, jid], !!useUserDevicesCache, true);
|
|
401
|
+
devices.push(...additionalDevices);
|
|
465
402
|
}
|
|
466
403
|
const allJids = [];
|
|
467
404
|
const meJids = [];
|
|
468
405
|
const otherJids = [];
|
|
469
406
|
for (const { user, device } of devices) {
|
|
470
|
-
const isMe = user === meUser
|
|
471
|
-
const jid = WABinary_1.jidEncode(isMe && isLid ? authState.creds
|
|
472
|
-
|
|
407
|
+
const isMe = user === meUser;
|
|
408
|
+
const jid = (0, WABinary_1.jidEncode)(isMe && isLid ? ((_f = (_e = authState.creds) === null || _e === void 0 ? void 0 : _e.me) === null || _f === void 0 ? void 0 : _f.lid.split(':')[0]) || user : user, isLid ? 'lid' : 's.whatsapp.net', device);
|
|
473
409
|
if (isMe) {
|
|
474
|
-
meJids.push(jid)
|
|
410
|
+
meJids.push(jid);
|
|
475
411
|
}
|
|
476
|
-
|
|
477
412
|
else {
|
|
478
|
-
otherJids.push(jid)
|
|
413
|
+
otherJids.push(jid);
|
|
479
414
|
}
|
|
480
|
-
|
|
481
|
-
allJids.push(jid)
|
|
415
|
+
allJids.push(jid);
|
|
482
416
|
}
|
|
483
417
|
await assertSessions(allJids, false);
|
|
484
418
|
const [{ nodes: meNodes, shouldIncludeDeviceIdentity: s1 }, { nodes: otherNodes, shouldIncludeDeviceIdentity: s2 }] = await Promise.all([
|
|
485
|
-
createParticipantNodes(meJids, meMsg,
|
|
486
|
-
createParticipantNodes(otherJids, message,
|
|
487
|
-
])
|
|
419
|
+
createParticipantNodes(meJids, meMsg, mediaType ? { mediatype: mediaType } : undefined),
|
|
420
|
+
createParticipantNodes(otherJids, message, mediaType ? { mediatype: mediaType } : undefined)
|
|
421
|
+
]);
|
|
488
422
|
participants.push(...meNodes);
|
|
489
423
|
participants.push(...otherNodes);
|
|
490
424
|
shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2;
|
|
491
425
|
}
|
|
492
426
|
if (participants.length) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
else {
|
|
502
|
-
binaryNodeContent.push({
|
|
503
|
-
tag: 'participants',
|
|
504
|
-
attrs: {},
|
|
505
|
-
content: participants
|
|
506
|
-
})
|
|
507
|
-
}
|
|
427
|
+
binaryNodeContent.push({
|
|
428
|
+
tag: 'participants',
|
|
429
|
+
attrs: {},
|
|
430
|
+
content: participants
|
|
431
|
+
});
|
|
508
432
|
}
|
|
509
|
-
|
|
510
433
|
const stanza = {
|
|
511
434
|
tag: 'message',
|
|
512
435
|
attrs: {
|
|
513
436
|
id: msgId,
|
|
514
|
-
type: getTypeMessage(
|
|
437
|
+
type: isNewsletter ? getTypeMessage(message) : 'text',
|
|
515
438
|
...(additionalAttributes || {})
|
|
516
439
|
},
|
|
517
440
|
content: binaryNodeContent
|
|
518
|
-
}
|
|
441
|
+
};
|
|
519
442
|
// if the participant to send to is explicitly specified (generally retry recp)
|
|
520
443
|
// ensure the message is only sent to that person
|
|
521
444
|
// if a retry receipt is sent to everyone -- it'll fail decryption for everyone else who received the msg
|
|
522
445
|
if (participant) {
|
|
523
|
-
if (WABinary_1.isJidGroup(destinationJid)) {
|
|
446
|
+
if ((0, WABinary_1.isJidGroup)(destinationJid)) {
|
|
524
447
|
stanza.attrs.to = destinationJid;
|
|
525
448
|
stanza.attrs.participant = participant.jid;
|
|
526
449
|
}
|
|
527
|
-
else if (WABinary_1.areJidsSameUser(participant.jid, meId)) {
|
|
450
|
+
else if ((0, WABinary_1.areJidsSameUser)(participant.jid, meId)) {
|
|
528
451
|
stanza.attrs.to = participant.jid;
|
|
529
452
|
stanza.attrs.recipient = destinationJid;
|
|
530
453
|
}
|
|
@@ -543,6 +466,28 @@ const makeMessagesSocket = (config) => {
|
|
|
543
466
|
});
|
|
544
467
|
logger.debug({ jid }, 'adding device identity');
|
|
545
468
|
}
|
|
469
|
+
if (additionalNodes && additionalNodes.length > 0) {
|
|
470
|
+
stanza.content.push(...additionalNodes);
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
if (((0, WABinary_1.isJidGroup)(jid) || (0, WABinary_1.isJidUser)(jid)) && ((message === null || message === void 0 ? void 0 : message.viewOnceMessage) ? message === null || message === void 0 ? void 0 : message.viewOnceMessage : (message === null || message === void 0 ? void 0 : message.viewOnceMessageV2) ? message === null || message === void 0 ? void 0 : message.viewOnceMessageV2 : (message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension) ? message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension : (message === null || message === void 0 ? void 0 : message.ephemeralMessage) ? message === null || message === void 0 ? void 0 : message.ephemeralMessage : (message === null || message === void 0 ? void 0 : message.templateMessage) ? message === null || message === void 0 ? void 0 : message.templateMessage : (message === null || message === void 0 ? void 0 : message.interactiveMessage) ? message === null || message === void 0 ? void 0 : message.interactiveMessage : message === null || message === void 0 ? void 0 : message.buttonsMessage)) {
|
|
474
|
+
stanza.content.push({
|
|
475
|
+
tag: 'biz',
|
|
476
|
+
attrs: {},
|
|
477
|
+
content: [{
|
|
478
|
+
tag: 'interactive',
|
|
479
|
+
attrs: {
|
|
480
|
+
type: 'native_flow',
|
|
481
|
+
v: '1'
|
|
482
|
+
},
|
|
483
|
+
content: [{
|
|
484
|
+
tag: 'native_flow',
|
|
485
|
+
attrs: { v: '9', name: 'mixed' }
|
|
486
|
+
}]
|
|
487
|
+
}]
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
}
|
|
546
491
|
|
|
547
492
|
if (AI && isPrivate) {
|
|
548
493
|
const botNode = {
|
|
@@ -552,7 +497,7 @@ const makeMessagesSocket = (config) => {
|
|
|
552
497
|
}
|
|
553
498
|
}
|
|
554
499
|
|
|
555
|
-
const filteredBizBot = WABinary_1.
|
|
500
|
+
const filteredBizBot = WABinary_1.getBinaryFilteredBizBot(additionalNodes ? additionalNodes : [])
|
|
556
501
|
|
|
557
502
|
if (filteredBizBot) {
|
|
558
503
|
stanza.content.push(...additionalNodes)
|
|
@@ -563,46 +508,24 @@ const makeMessagesSocket = (config) => {
|
|
|
563
508
|
stanza.content.push(botNode)
|
|
564
509
|
}
|
|
565
510
|
}
|
|
566
|
-
|
|
567
|
-
if(
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
578
|
-
logger.debug({ jid }, 'adding business node')
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
if (!didPushAdditional && additionalNodes && additionalNodes.length > 0) {
|
|
582
|
-
stanza.content.push(...additionalNodes);
|
|
511
|
+
const buttonType = getButtonType(message);
|
|
512
|
+
if (buttonType) {
|
|
513
|
+
stanza.content.push({
|
|
514
|
+
tag: 'biz',
|
|
515
|
+
attrs: {},
|
|
516
|
+
content: [
|
|
517
|
+
{
|
|
518
|
+
tag: buttonType,
|
|
519
|
+
attrs: getButtonArgs(message),
|
|
520
|
+
}
|
|
521
|
+
]
|
|
522
|
+
});
|
|
523
|
+
logger.debug({ jid }, 'adding business node');
|
|
583
524
|
}
|
|
584
|
-
|
|
585
525
|
logger.debug({ msgId }, `sending message to ${participants.length} devices`);
|
|
586
526
|
await sendNode(stanza);
|
|
587
527
|
});
|
|
588
|
-
|
|
589
|
-
message = Types_1.WAProto.Message.fromObject(message)
|
|
590
|
-
|
|
591
|
-
const messageJSON = {
|
|
592
|
-
key: {
|
|
593
|
-
remoteJid: jid,
|
|
594
|
-
fromMe: true,
|
|
595
|
-
id: msgId
|
|
596
|
-
},
|
|
597
|
-
message: message,
|
|
598
|
-
messageTimestamp: Utils_1.unixTimestampSeconds(new Date()),
|
|
599
|
-
messageStubParameters: [],
|
|
600
|
-
participant: WABinary_1.isJidGroup(jid) || WABinary_1.isJidStatusBroadcast(jid) ? meId : undefined,
|
|
601
|
-
status: Types_1.WAMessageStatus.PENDING
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
return Types_1.WAProto.WebMessageInfo.fromObject(messageJSON)
|
|
605
|
-
// return msgId;
|
|
528
|
+
return msgId;
|
|
606
529
|
};
|
|
607
530
|
const getTypeMessage = (msg) => {
|
|
608
531
|
const message = Utils_1.normalizeMessageContent(msg)
|
|
@@ -667,38 +590,93 @@ const makeMessagesSocket = (config) => {
|
|
|
667
590
|
return 'productlink'
|
|
668
591
|
}
|
|
669
592
|
}
|
|
670
|
-
|
|
671
593
|
const getButtonType = (message) => {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
594
|
+
if (message.listMessage) {
|
|
595
|
+
return 'list'
|
|
596
|
+
}
|
|
675
597
|
else if (message.buttonsMessage) {
|
|
676
598
|
return 'buttons'
|
|
677
599
|
}
|
|
678
|
-
else if
|
|
679
|
-
return 'review_and_pay'
|
|
680
|
-
}
|
|
681
|
-
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_order') {
|
|
682
|
-
return 'review_order'
|
|
683
|
-
}
|
|
684
|
-
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_info') {
|
|
685
|
-
return 'payment_info'
|
|
686
|
-
}
|
|
687
|
-
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_status') {
|
|
688
|
-
return 'payment_status'
|
|
689
|
-
}
|
|
690
|
-
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_method') {
|
|
691
|
-
return 'payment_method'
|
|
692
|
-
}
|
|
693
|
-
else if (message.interactiveMessage && message.interactiveMessage?.nativeFlowMessage) {
|
|
694
|
-
return 'interactive'
|
|
695
|
-
}
|
|
696
|
-
else if (message.interactiveMessage?.nativeFlowMessage) {
|
|
600
|
+
else if(message.interactiveMessage?.nativeFlowMessage) {
|
|
697
601
|
return 'native_flow'
|
|
698
602
|
}
|
|
699
603
|
}
|
|
604
|
+
const getButtonArgs = (message) => {
|
|
605
|
+
if (message.interactiveMessage?.nativeFlowMessage && message.interactiveMessage.nativeFlowMessage?.buttons?.length > 0 && message.interactiveMessage.nativeFlowMessage.buttons[0].name === 'review_and_pay') {
|
|
606
|
+
return {
|
|
607
|
+
tag: 'biz',
|
|
608
|
+
attrs: {
|
|
609
|
+
native_flow_name: 'order_details'
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
} else if (message.interactiveMessage?.nativeFlowMessage && message.interactiveMessage.nativeFlowMessage?.buttons?.length > 0 && message.interactiveMessage.nativeFlowMessage.buttons[0].name === 'payment_info') {
|
|
613
|
+
return {
|
|
614
|
+
tag: 'biz',
|
|
615
|
+
attrs: {
|
|
616
|
+
native_flow_name: 'payment_info'
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
} else if (message.interactiveMessage?.nativeFlowMessage &&message.interactiveMessage.nativeFlowMessage?.buttons?.length > 0 &&
|
|
620
|
+
['mpm', 'cta_catalog', 'send_location', 'call_permission_request', 'wa_payment_transaction_details', 'automated_greeting_message_view_catalog']
|
|
621
|
+
.includes(message.interactiveMessage.nativeFlowMessage.buttons[0].name)) {
|
|
622
|
+
return {
|
|
623
|
+
tag: 'biz',
|
|
624
|
+
attrs: {},
|
|
625
|
+
content: [{
|
|
626
|
+
tag: 'interactive',
|
|
627
|
+
attrs: {
|
|
628
|
+
type: 'native_flow',
|
|
629
|
+
v: '1'
|
|
630
|
+
},
|
|
631
|
+
content: [{
|
|
632
|
+
tag: 'native_flow',
|
|
633
|
+
attrs: {
|
|
634
|
+
v: '2',
|
|
635
|
+
name: message.interactiveMessage.nativeFlowMessage.buttons[0].name
|
|
636
|
+
}
|
|
637
|
+
}]
|
|
638
|
+
}]
|
|
639
|
+
}
|
|
640
|
+
} else if (message.interactiveMessage?.nativeFlowMessage || message.buttonsMessage) {
|
|
641
|
+
return {
|
|
642
|
+
tag: 'biz',
|
|
643
|
+
attrs: {},
|
|
644
|
+
content: [{
|
|
645
|
+
tag: 'interactive',
|
|
646
|
+
attrs: {
|
|
647
|
+
type: 'native_flow',
|
|
648
|
+
v: '1'
|
|
649
|
+
},
|
|
650
|
+
content: [{
|
|
651
|
+
tag: 'native_flow',
|
|
652
|
+
attrs: {
|
|
653
|
+
v: '9',
|
|
654
|
+
name: 'mixed'
|
|
655
|
+
}
|
|
656
|
+
}]
|
|
657
|
+
}]
|
|
658
|
+
}
|
|
659
|
+
} else if (message.listMessage) {
|
|
660
|
+
return {
|
|
661
|
+
tag: 'biz',
|
|
662
|
+
attrs: {},
|
|
663
|
+
content: [{
|
|
664
|
+
tag: 'list',
|
|
665
|
+
attrs: {
|
|
666
|
+
v: '2',
|
|
667
|
+
type: 'product_list'
|
|
668
|
+
}
|
|
669
|
+
}]
|
|
670
|
+
}
|
|
671
|
+
} else {
|
|
672
|
+
return {
|
|
673
|
+
tag: 'biz',
|
|
674
|
+
attrs: {}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
700
678
|
const getPrivacyTokens = async (jids) => {
|
|
701
|
-
const t = Utils_1.unixTimestampSeconds().toString();
|
|
679
|
+
const t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
702
680
|
const result = await query({
|
|
703
681
|
tag: 'iq',
|
|
704
682
|
attrs: {
|
|
@@ -713,7 +691,7 @@ const makeMessagesSocket = (config) => {
|
|
|
713
691
|
content: jids.map(jid => ({
|
|
714
692
|
tag: 'token',
|
|
715
693
|
attrs: {
|
|
716
|
-
jid: WABinary_1.jidNormalizedUser(jid),
|
|
694
|
+
jid: (0, WABinary_1.jidNormalizedUser)(jid),
|
|
717
695
|
t,
|
|
718
696
|
type: 'trusted_contact'
|
|
719
697
|
}
|
|
@@ -722,9 +700,31 @@ const makeMessagesSocket = (config) => {
|
|
|
722
700
|
]
|
|
723
701
|
});
|
|
724
702
|
return result;
|
|
725
|
-
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
const sendPeerDataOperationMessage = async (pdoMessage) => {
|
|
706
|
+
var _a;
|
|
707
|
+
//TODO: for later, abstract the logic to send a Peer Message instead of just PDO - useful for App State Key Resync with phone
|
|
708
|
+
if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
709
|
+
throw new boom_1.Boom('Not authenticated');
|
|
710
|
+
}
|
|
711
|
+
const protocolMessage = {
|
|
712
|
+
protocolMessage: {
|
|
713
|
+
peerDataOperationRequestMessage: pdoMessage,
|
|
714
|
+
type: WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
const meJid = (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id);
|
|
718
|
+
const msgId = await relayMessage(meJid, protocolMessage, {
|
|
719
|
+
additionalAttributes: {
|
|
720
|
+
category: 'peer',
|
|
721
|
+
// eslint-disable-next-line camelcase
|
|
722
|
+
push_priority: 'high_force',
|
|
723
|
+
},
|
|
724
|
+
});
|
|
725
|
+
return msgId;
|
|
726
|
+
};
|
|
726
727
|
const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
|
|
727
|
-
const luki = new imup(Utils_1, waUploadToServer, relayMessage);
|
|
728
728
|
const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
|
|
729
729
|
return {
|
|
730
730
|
...sock,
|
|
@@ -733,7 +733,7 @@ const makeMessagesSocket = (config) => {
|
|
|
733
733
|
relayMessage,
|
|
734
734
|
sendReceipt,
|
|
735
735
|
sendReceipts,
|
|
736
|
-
|
|
736
|
+
getButtonArgs,
|
|
737
737
|
readMessages,
|
|
738
738
|
refreshMediaConn,
|
|
739
739
|
getUSyncDevices,
|
|
@@ -778,74 +778,96 @@ const makeMessagesSocket = (config) => {
|
|
|
778
778
|
throw error;
|
|
779
779
|
}
|
|
780
780
|
ev.emit('messages.update', [
|
|
781
|
-
{
|
|
782
|
-
key: message.key,
|
|
783
|
-
update: {
|
|
784
|
-
message: message.message
|
|
785
|
-
}
|
|
786
|
-
}
|
|
781
|
+
{ key: message.key, update: { message: message.message } }
|
|
787
782
|
]);
|
|
788
783
|
return message;
|
|
789
784
|
},
|
|
790
785
|
sendMessage: async (jid, content, options = {}) => {
|
|
791
786
|
const userJid = authState.creds.me.id;
|
|
792
|
-
delete options.ephemeralExpiration
|
|
793
787
|
const { filter = false, quoted } = options;
|
|
794
|
-
const getParticipantAttr = () =>
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
const value = typeof disappearingMessagesInChat === 'boolean' ?
|
|
801
|
-
(disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0) :
|
|
802
|
-
disappearingMessagesInChat
|
|
803
|
-
|
|
804
|
-
await groupToggleEphemeral(jid, value)
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
else {
|
|
808
|
-
let mediaHandle
|
|
788
|
+
const getParticipantAttr = () => {
|
|
789
|
+
return filter ? {
|
|
790
|
+
participant: { jid }
|
|
791
|
+
} : {};
|
|
792
|
+
};
|
|
809
793
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
794
|
+
if ('productMessage' in content) {
|
|
795
|
+
const { title, description, thumbnail, productId, retailerId, url, body = "", footer = "", buttons = [] } = content.productMessage;
|
|
796
|
+
const { imageMessage } = await Utils_1.generateWAMessageContent(
|
|
797
|
+
{ image: { url: thumbnail }},
|
|
798
|
+
{ upload: waUploadToServer });
|
|
799
|
+
|
|
800
|
+
const msg = await Utils_1.generateWAMessageFromContent(jid, {
|
|
801
|
+
viewOnceMessage: {
|
|
802
|
+
message: {
|
|
803
|
+
interactiveMessage: {
|
|
804
|
+
body: { text: body },
|
|
805
|
+
footer: { text: footer },
|
|
806
|
+
header: {
|
|
807
|
+
title,
|
|
808
|
+
hasMediaAttachment: true,
|
|
809
|
+
productMessage: {
|
|
810
|
+
product: {
|
|
811
|
+
productImage: imageMessage,
|
|
812
|
+
productId,
|
|
813
|
+
title,
|
|
814
|
+
description,
|
|
815
|
+
currencyCode: "IDR",
|
|
816
|
+
priceAmount1000: null,
|
|
817
|
+
retailerId,
|
|
818
|
+
url,
|
|
819
|
+
productImageCount: 1
|
|
820
|
+
},
|
|
821
|
+
businessOwnerJid: "0@s.whatsapp.net"
|
|
822
|
+
}
|
|
823
|
+
},
|
|
824
|
+
nativeFlowMessage: { buttons }
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}, { quoted });
|
|
819
829
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
830
|
+
return await relayMessage(jid, msg.message, {
|
|
831
|
+
messageId: msg.key.id,
|
|
832
|
+
...getParticipantAttr()
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
if ('interactiveMessage' in content) {
|
|
836
|
+
const { title, footer, thumbnail, buttons = [] } = content.interactiveMessage;
|
|
837
|
+
const header = thumbnail ? WAProto_1.proto.Message.InteractiveMessage.Header.create({
|
|
838
|
+
title: "",
|
|
839
|
+
hasMediaAttachment: true,
|
|
840
|
+
...(await Utils_1.prepareWAMessageMedia(
|
|
841
|
+
{ image: { url: thumbnail } },
|
|
842
|
+
{ upload: waUploadToServer }
|
|
843
|
+
))
|
|
844
|
+
}) : WAProto_1.proto.Message.InteractiveMessage.Header.create({
|
|
845
|
+
title: "",
|
|
846
|
+
hasMediaAttachment: false
|
|
847
|
+
});
|
|
848
|
+
const msg = await Utils_1.generateWAMessageFromContent(jid, {
|
|
849
|
+
viewOnceMessage: {
|
|
850
|
+
message: {
|
|
851
|
+
messageContextInfo: {
|
|
852
|
+
deviceListMetadata: {},
|
|
853
|
+
deviceListMetadataVersion: 2
|
|
854
|
+
},
|
|
855
|
+
interactiveMessage: WAProto_1.proto.Message.InteractiveMessage.create({
|
|
856
|
+
body: { text: title },
|
|
857
|
+
footer: { text: footer },
|
|
858
|
+
header,
|
|
859
|
+
nativeFlowMessage: { buttons }
|
|
860
|
+
})
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}, { quoted });
|
|
827
864
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
messageId: interactiveMsg.key.id,
|
|
833
|
-
...getParticipantAttr()
|
|
834
|
-
});
|
|
835
|
-
case 'ALBUM':
|
|
836
|
-
return await luki.handleAlbum(content, jid, quoted)
|
|
837
|
-
case 'EVENT':
|
|
838
|
-
return await luki.handleEvent(content, jid, quoted)
|
|
839
|
-
case 'POLL_RESULT':
|
|
840
|
-
return await luki.handlePollResult(content, jid, quoted)
|
|
841
|
-
case 'STATUS_MENTION':
|
|
842
|
-
return await luki.handleStMention(content, jid, quoted)
|
|
843
|
-
case 'ORDER':
|
|
844
|
-
return await luki.handleOrderMessage(content, jid, quoted)
|
|
845
|
-
case 'GROUP_STATUS':
|
|
846
|
-
return await luki.handleGroupStory(content, jid, quoted)
|
|
847
|
-
}
|
|
865
|
+
return await relayMessage(jid, msg.message, {
|
|
866
|
+
messageId: msg.key.id,
|
|
867
|
+
...getParticipantAttr()
|
|
868
|
+
});
|
|
848
869
|
}
|
|
870
|
+
|
|
849
871
|
const fullMsg = await Utils_1.generateWAMessage(jid, content, {
|
|
850
872
|
logger,
|
|
851
873
|
userJid,
|
|
@@ -870,14 +892,14 @@ const makeMessagesSocket = (config) => {
|
|
|
870
892
|
options: config.options,
|
|
871
893
|
...options
|
|
872
894
|
});
|
|
873
|
-
|
|
895
|
+
|
|
874
896
|
const isDeleteMsg = 'delete' in content && !!content.delete;
|
|
875
897
|
const isEditMsg = 'edit' in content && !!content.edit;
|
|
876
898
|
const isAiMsg = 'ai' in content && !!content.ai;
|
|
877
899
|
|
|
878
900
|
const additionalAttributes = {};
|
|
879
901
|
const additionalNodes = [];
|
|
880
|
-
|
|
902
|
+
|
|
881
903
|
if (isDeleteMsg) {
|
|
882
904
|
const fromMe = content.delete?.fromMe;
|
|
883
905
|
const isGroup = WABinary_1.isJidGroup(content.delete?.remoteJid);
|
|
@@ -891,7 +913,7 @@ const makeMessagesSocket = (config) => {
|
|
|
891
913
|
}, tag: "bot"
|
|
892
914
|
});
|
|
893
915
|
}
|
|
894
|
-
|
|
916
|
+
|
|
895
917
|
await relayMessage(jid, fullMsg.message, {
|
|
896
918
|
messageId: fullMsg.key.id,
|
|
897
919
|
cachedGroupMetadata: options.cachedGroupMetadata,
|
|
@@ -906,7 +928,6 @@ const makeMessagesSocket = (config) => {
|
|
|
906
928
|
});
|
|
907
929
|
}
|
|
908
930
|
return fullMsg;
|
|
909
|
-
}
|
|
910
931
|
}
|
|
911
932
|
}
|
|
912
933
|
};
|