gifted-baileys 1.5.0 → 1.5.4
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/LICENSE +1 -1
- package/README.md +1429 -684
- package/WAProto/WAProto.proto +969 -88
- package/WAProto/index.d.ts +13199 -1260
- package/WAProto/index.js +124901 -74525
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +2 -2
- package/lib/Defaults/index.js +6 -5
- package/lib/Defaults/phonenumber-mcc.json +221 -221
- package/lib/Signal/libsignal.js +18 -9
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -2
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -1
- package/lib/Socket/Client/types.d.ts +17 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
- package/lib/Socket/business.d.ts +64 -29
- package/lib/Socket/business.js +1 -0
- package/lib/Socket/chats.d.ts +10 -8
- package/lib/Socket/chats.js +114 -97
- package/lib/Socket/groups.d.ts +10 -8
- package/lib/Socket/groups.js +4 -2
- package/lib/Socket/index.d.ts +70 -35
- package/lib/Socket/messages-recv.d.ts +63 -29
- package/lib/Socket/messages-recv.js +374 -155
- package/lib/Socket/messages-send.d.ts +48 -12
- package/lib/Socket/messages-send.js +445 -87
- package/lib/Socket/newsletter.d.ts +132 -0
- package/lib/Socket/newsletter.js +236 -0
- package/lib/Socket/registration.d.ts +73 -41
- package/lib/Socket/registration.js +7 -7
- package/lib/Socket/socket.d.ts +2 -0
- package/lib/Socket/socket.js +56 -15
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/make-cache-manager-store.d.ts +2 -1
- package/lib/Store/make-in-memory-store.d.ts +2 -1
- package/lib/Store/make-in-memory-store.js +40 -46
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Types/Auth.d.ts +2 -1
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +12 -7
- package/lib/Types/Events.d.ts +17 -2
- package/lib/Types/GroupMetadata.d.ts +6 -2
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +184 -12
- package/lib/Types/Newsletter.d.ts +92 -0
- package/lib/Types/Newsletter.js +32 -0
- package/lib/Types/Socket.d.ts +7 -2
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +10 -0
- package/lib/Types/index.js +2 -1
- package/lib/Utils/auth-utils.js +5 -3
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +11 -12
- package/lib/Utils/chat-utils.js +41 -20
- package/lib/Utils/crypto.d.ts +15 -16
- package/lib/Utils/crypto.js +35 -23
- package/lib/Utils/decode-wa-message.d.ts +17 -0
- package/lib/Utils/decode-wa-message.js +65 -13
- package/lib/Utils/generics.d.ts +11 -17
- package/lib/Utils/generics.js +47 -13
- package/lib/Utils/history.d.ts +6 -2
- package/lib/Utils/history.js +3 -0
- package/lib/Utils/link-preview.js +1 -1
- package/lib/Utils/logger.d.ts +1 -3
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +31 -25
- package/lib/Utils/messages-media.js +95 -53
- package/lib/Utils/messages.d.ts +2 -1
- package/lib/Utils/messages.js +515 -34
- package/lib/Utils/noise-handler.d.ts +6 -6
- package/lib/Utils/noise-handler.js +16 -3
- package/lib/Utils/process-message.js +4 -3
- package/lib/Utils/signal.d.ts +2 -1
- package/lib/Utils/signal.js +11 -19
- package/lib/Utils/use-multi-file-auth-state.js +11 -3
- package/lib/Utils/validate-connection.js +16 -2
- package/lib/WABinary/decode.d.ts +1 -2
- package/lib/WABinary/decode.js +17 -7
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +33 -17
- package/lib/WABinary/generic-utils.d.ts +2 -3
- package/lib/WABinary/generic-utils.js +2 -2
- package/lib/WABinary/jid-utils.d.ts +4 -2
- package/lib/WABinary/jid-utils.js +4 -1
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.d.ts +26 -0
- package/lib/WAUSync/USyncQuery.js +79 -0
- package/lib/WAUSync/USyncUser.d.ts +10 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/gifted +1 -0
- package/lib/index.js +2 -0
- package/package.json +10 -7
- package/lib/index.d.ts +0 -10
|
@@ -8,15 +8,17 @@ 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 Types_1 = require("../Types");
|
|
11
12
|
const Utils_1 = require("../Utils");
|
|
12
13
|
const link_preview_1 = require("../Utils/link-preview");
|
|
13
14
|
const WABinary_1 = require("../WABinary");
|
|
14
|
-
const
|
|
15
|
+
const WAUSync_1 = require("../WAUSync");
|
|
16
|
+
const newsletter_1 = require("./newsletter");
|
|
15
17
|
var ListType = WAProto_1.proto.Message.ListMessage.ListType;
|
|
16
18
|
const makeMessagesSocket = (config) => {
|
|
17
19
|
const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, } = config;
|
|
18
|
-
const sock = (0,
|
|
19
|
-
const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, generateMessageTag, sendNode, groupMetadata, groupToggleEphemeral } = sock;
|
|
20
|
+
const sock = (0, newsletter_1.makeNewsletterSocket)(config);
|
|
21
|
+
const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, generateMessageTag, sendNode, groupMetadata, groupQuery, newsletterWMexQuery, groupToggleEphemeral } = sock;
|
|
20
22
|
const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
|
|
21
23
|
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES,
|
|
22
24
|
useClones: false
|
|
@@ -77,7 +79,7 @@ const makeMessagesSocket = (config) => {
|
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
if (type) {
|
|
80
|
-
node.attrs.type = type;
|
|
82
|
+
node.attrs.type = (0, WABinary_1.isJidNewsLetter)(jid) ? 'read-self' : type;
|
|
81
83
|
}
|
|
82
84
|
const remainingMessageIds = messageIds.slice(1);
|
|
83
85
|
if (remainingMessageIds.length) {
|
|
@@ -109,6 +111,43 @@ const makeMessagesSocket = (config) => {
|
|
|
109
111
|
const readType = privacySettings.readreceipts === 'all' ? 'read' : 'read-self';
|
|
110
112
|
await sendReceipts(keys, readType);
|
|
111
113
|
};
|
|
114
|
+
const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
|
|
115
|
+
var _a, _b, _c, _d;
|
|
116
|
+
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
117
|
+
if ((0, WABinary_1.isJidNewsLetter)(jid)) {
|
|
118
|
+
const node = await newsletterWMexQuery(undefined, Types_1.QueryIds.METADATA, {
|
|
119
|
+
input: {
|
|
120
|
+
key: jid,
|
|
121
|
+
type: "JID",
|
|
122
|
+
'view_role': 'GUEST'
|
|
123
|
+
},
|
|
124
|
+
'fetch_viewer_metadata': true,
|
|
125
|
+
'fetch_full_image': true,
|
|
126
|
+
'fetch_creation_time': true
|
|
127
|
+
});
|
|
128
|
+
const result = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(node, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
|
|
129
|
+
const metadataPath = JSON.parse(result).data[Types_1.XWAPaths.NEWSLETTER];
|
|
130
|
+
const pictype = type === 'image' ? 'picture' : 'preview';
|
|
131
|
+
const directPath = (_c = metadataPath === null || metadataPath === void 0 ? void 0 : metadataPath.thread_metadata[pictype]) === null || _c === void 0 ? void 0 : _c.direct_path;
|
|
132
|
+
return directPath ? (0, Utils_1.getUrlFromDirectPath)(directPath) : null;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const result = await query({
|
|
136
|
+
tag: 'iq',
|
|
137
|
+
attrs: {
|
|
138
|
+
target: jid,
|
|
139
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
140
|
+
type: 'get',
|
|
141
|
+
xmlns: 'w:profile:picture'
|
|
142
|
+
},
|
|
143
|
+
content: [
|
|
144
|
+
{ tag: 'picture', attrs: { type, query: 'url' } }
|
|
145
|
+
]
|
|
146
|
+
}, timeoutMs);
|
|
147
|
+
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'picture');
|
|
148
|
+
return (_d = child === null || child === void 0 ? void 0 : child.attrs) === null || _d === void 0 ? void 0 : _d.url;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
112
151
|
/** Fetch all the devices we've to send a message to */
|
|
113
152
|
const getUSyncDevices = async (jids, useCache, ignoreZeroDevices) => {
|
|
114
153
|
var _a;
|
|
@@ -116,63 +155,46 @@ const makeMessagesSocket = (config) => {
|
|
|
116
155
|
if (!useCache) {
|
|
117
156
|
logger.debug('not using cache for devices');
|
|
118
157
|
}
|
|
119
|
-
const
|
|
158
|
+
const toFetch = [];
|
|
120
159
|
jids = Array.from(new Set(jids));
|
|
121
160
|
for (let jid of jids) {
|
|
122
161
|
const user = (_a = (0, WABinary_1.jidDecode)(jid)) === null || _a === void 0 ? void 0 : _a.user;
|
|
123
162
|
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
163
|
+
if (useCache) {
|
|
164
|
+
const devices = userDevicesCache.get(user);
|
|
165
|
+
if (devices) {
|
|
166
|
+
deviceResults.push(...devices);
|
|
167
|
+
logger.trace({ user }, 'using cache for devices');
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
toFetch.push(jid);
|
|
171
|
+
}
|
|
128
172
|
}
|
|
129
173
|
else {
|
|
130
|
-
|
|
174
|
+
toFetch.push(jid);
|
|
131
175
|
}
|
|
132
176
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
content: [
|
|
155
|
-
{
|
|
156
|
-
tag: 'devices',
|
|
157
|
-
attrs: { version: '2' }
|
|
158
|
-
}
|
|
159
|
-
]
|
|
160
|
-
},
|
|
161
|
-
{ tag: 'list', attrs: {}, content: users }
|
|
162
|
-
]
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
};
|
|
166
|
-
const result = await query(iq);
|
|
167
|
-
const extracted = (0, Utils_1.extractDeviceJids)(result, authState.creds.me.id, ignoreZeroDevices);
|
|
168
|
-
const deviceMap = {};
|
|
169
|
-
for (const item of extracted) {
|
|
170
|
-
deviceMap[item.user] = deviceMap[item.user] || [];
|
|
171
|
-
deviceMap[item.user].push(item);
|
|
172
|
-
deviceResults.push(item);
|
|
173
|
-
}
|
|
174
|
-
for (const key in deviceMap) {
|
|
175
|
-
userDevicesCache.set(key, deviceMap[key]);
|
|
177
|
+
if (!toFetch.length) {
|
|
178
|
+
return deviceResults;
|
|
179
|
+
}
|
|
180
|
+
const query = new WAUSync_1.USyncQuery()
|
|
181
|
+
.withContext('message')
|
|
182
|
+
.withDeviceProtocol();
|
|
183
|
+
for (const jid of toFetch) {
|
|
184
|
+
query.withUser(new WAUSync_1.USyncUser().withId(jid));
|
|
185
|
+
}
|
|
186
|
+
const result = await sock.executeUSyncQuery(query);
|
|
187
|
+
if (result) {
|
|
188
|
+
const extracted = (0, Utils_1.extractDeviceJids)(result === null || result === void 0 ? void 0 : result.list, 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
|
+
}
|
|
176
198
|
}
|
|
177
199
|
return deviceResults;
|
|
178
200
|
};
|
|
@@ -219,6 +241,28 @@ const makeMessagesSocket = (config) => {
|
|
|
219
241
|
}
|
|
220
242
|
return didFetchNewSession;
|
|
221
243
|
};
|
|
244
|
+
const sendPeerDataOperationMessage = async (pdoMessage) => {
|
|
245
|
+
var _a;
|
|
246
|
+
//TODO: for later, abstract the logic to send a Peer Message instead of just PDO - useful for App State Key Resync with phone
|
|
247
|
+
if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
248
|
+
throw new boom_1.Boom('Not authenticated');
|
|
249
|
+
}
|
|
250
|
+
const protocolMessage = {
|
|
251
|
+
protocolMessage: {
|
|
252
|
+
peerDataOperationRequestMessage: pdoMessage,
|
|
253
|
+
type: WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const meJid = (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id);
|
|
257
|
+
const msgId = await relayMessage(meJid, protocolMessage, {
|
|
258
|
+
additionalAttributes: {
|
|
259
|
+
category: 'peer',
|
|
260
|
+
// eslint-disable-next-line camelcase
|
|
261
|
+
push_priority: 'high_force',
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
return msgId;
|
|
265
|
+
};
|
|
222
266
|
const createParticipantNodes = async (jids, message, extraAttrs) => {
|
|
223
267
|
const patched = await patchMessageBeforeSending(message, jids);
|
|
224
268
|
const bytes = (0, Utils_1.encodeWAMessage)(patched);
|
|
@@ -245,8 +289,8 @@ const makeMessagesSocket = (config) => {
|
|
|
245
289
|
return node;
|
|
246
290
|
}));
|
|
247
291
|
return { nodes, shouldIncludeDeviceIdentity };
|
|
248
|
-
};
|
|
249
|
-
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, useUserDevicesCache, cachedGroupMetadata, statusJidList }) => {
|
|
292
|
+
}; //apela
|
|
293
|
+
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }) => {
|
|
250
294
|
const meId = authState.creds.me.id;
|
|
251
295
|
let shouldIncludeDeviceIdentity = false;
|
|
252
296
|
const { user, server } = (0, WABinary_1.jidDecode)(jid);
|
|
@@ -254,10 +298,12 @@ const makeMessagesSocket = (config) => {
|
|
|
254
298
|
const isGroup = server === 'g.us';
|
|
255
299
|
const isStatus = jid === statusJid;
|
|
256
300
|
const isLid = server === 'lid';
|
|
301
|
+
const isPrivate = server === 's.whatsapp.net';
|
|
302
|
+
const isNewsletter = server === 'newsletter';
|
|
257
303
|
msgId = msgId || (0, Utils_1.generateMessageID)();
|
|
258
304
|
useUserDevicesCache = useUserDevicesCache !== false;
|
|
259
305
|
const participants = [];
|
|
260
|
-
const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' : 's.whatsapp.net') : statusJid;
|
|
306
|
+
const destinationJid = (!isStatus) ? (0, WABinary_1.jidEncode)(user, isLid ? 'lid' : isGroup ? 'g.us' : isNewsletter ? 'newsletter' : 's.whatsapp.net') : statusJid;
|
|
261
307
|
const binaryNodeContent = [];
|
|
262
308
|
const devices = [];
|
|
263
309
|
const meMsg = {
|
|
@@ -277,7 +323,7 @@ const makeMessagesSocket = (config) => {
|
|
|
277
323
|
devices.push({ user, device });
|
|
278
324
|
}
|
|
279
325
|
await authState.keys.transaction(async () => {
|
|
280
|
-
var _a, _b;
|
|
326
|
+
var _a, _b, _c, _d, _e, _f;
|
|
281
327
|
const mediaType = getMediaType(message);
|
|
282
328
|
if (isGroup || isStatus) {
|
|
283
329
|
const [groupData, senderKeyMap] = await Promise.all([
|
|
@@ -307,7 +353,7 @@ const makeMessagesSocket = (config) => {
|
|
|
307
353
|
const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false);
|
|
308
354
|
devices.push(...additionalDevices);
|
|
309
355
|
}
|
|
310
|
-
const patched = await patchMessageBeforeSending(message, devices.map(d => (0, WABinary_1.jidEncode)(d.user, isLid ? 'lid' : 's.whatsapp.net', d.device)));
|
|
356
|
+
const patched = await patchMessageBeforeSending(message, devices.map(d => (0, WABinary_1.jidEncode)(d.user, isLid ? 'lid' : isGroup ? 'g.us' : isNewsletter ? 'newsletter' : 's.whatsapp.net', d.device)));
|
|
311
357
|
const bytes = (0, Utils_1.encodeWAMessage)(patched);
|
|
312
358
|
const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({
|
|
313
359
|
group: destinationJid,
|
|
@@ -346,6 +392,25 @@ const makeMessagesSocket = (config) => {
|
|
|
346
392
|
});
|
|
347
393
|
await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
|
|
348
394
|
}
|
|
395
|
+
else if (isNewsletter) {
|
|
396
|
+
// Message edit
|
|
397
|
+
if ((_a = message.protocolMessage) === null || _a === void 0 ? void 0 : _a.editedMessage) {
|
|
398
|
+
msgId = (_b = message.protocolMessage.key) === null || _b === void 0 ? void 0 : _b.id;
|
|
399
|
+
message = message.protocolMessage.editedMessage;
|
|
400
|
+
}
|
|
401
|
+
// Message delete
|
|
402
|
+
if (((_c = message.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE) {
|
|
403
|
+
msgId = (_d = message.protocolMessage.key) === null || _d === void 0 ? void 0 : _d.id;
|
|
404
|
+
message = {};
|
|
405
|
+
}
|
|
406
|
+
const patched = await patchMessageBeforeSending(message, []);
|
|
407
|
+
const bytes = WAProto_1.proto.Message.encode(patched).finish();
|
|
408
|
+
binaryNodeContent.push({
|
|
409
|
+
tag: 'plaintext',
|
|
410
|
+
attrs: mediaType ? { mediatype: mediaType } : {},
|
|
411
|
+
content: bytes
|
|
412
|
+
});
|
|
413
|
+
}
|
|
349
414
|
else {
|
|
350
415
|
const { user: meUser, device: meDevice } = (0, WABinary_1.jidDecode)(meId);
|
|
351
416
|
if (!participant) {
|
|
@@ -362,7 +427,7 @@ const makeMessagesSocket = (config) => {
|
|
|
362
427
|
const otherJids = [];
|
|
363
428
|
for (const { user, device } of devices) {
|
|
364
429
|
const isMe = user === meUser;
|
|
365
|
-
const jid = (0, WABinary_1.jidEncode)(isMe && isLid ? ((
|
|
430
|
+
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' : isGroup ? 'g.us' : isNewsletter ? 'newsletter' : 's.whatsapp.net', device);
|
|
366
431
|
if (isMe) {
|
|
367
432
|
meJids.push(jid);
|
|
368
433
|
}
|
|
@@ -391,7 +456,7 @@ const makeMessagesSocket = (config) => {
|
|
|
391
456
|
tag: 'message',
|
|
392
457
|
attrs: {
|
|
393
458
|
id: msgId,
|
|
394
|
-
type: 'text',
|
|
459
|
+
type: isNewsletter ? getTypeMessage(message) : 'text',
|
|
395
460
|
...(additionalAttributes || {})
|
|
396
461
|
},
|
|
397
462
|
content: binaryNodeContent
|
|
@@ -423,15 +488,58 @@ const makeMessagesSocket = (config) => {
|
|
|
423
488
|
});
|
|
424
489
|
logger.debug({ jid }, 'adding device identity');
|
|
425
490
|
}
|
|
426
|
-
|
|
427
|
-
|
|
491
|
+
if (additionalNodes && additionalNodes.length > 0) {
|
|
492
|
+
stanza.content.push(...additionalNodes);
|
|
493
|
+
}
|
|
494
|
+
const inMsg = (0, Utils_1.normalizeMessageContent)(message) || null;
|
|
495
|
+
const key = inMsg ? (0, Utils_1.getContentType)(inMsg) : null;
|
|
496
|
+
if (!isNewsletter && (key === 'interactiveMessage' || key === 'buttonsMessage')) {
|
|
497
|
+
const nativeNode = {
|
|
498
|
+
tag: 'biz',
|
|
499
|
+
attrs: {},
|
|
500
|
+
content: [{
|
|
501
|
+
tag: 'interactive',
|
|
502
|
+
attrs: {
|
|
503
|
+
type: 'native_flow',
|
|
504
|
+
v: '1'
|
|
505
|
+
},
|
|
506
|
+
content: [{
|
|
507
|
+
tag: 'native_flow',
|
|
508
|
+
attrs: {
|
|
509
|
+
name: 'quick_reply'
|
|
510
|
+
}
|
|
511
|
+
}]
|
|
512
|
+
}]
|
|
513
|
+
};
|
|
514
|
+
const resultNativeNode = filterNativeNode(additionalNodes);
|
|
515
|
+
if (resultNativeNode && additionalNodes && additionalNodes.length > 0) {
|
|
516
|
+
stanza.content.push(...resultNativeNode);
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
stanza.content.push(nativeNode);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (isPrivate) {
|
|
523
|
+
const botNode = {
|
|
524
|
+
tag: 'bot',
|
|
525
|
+
attrs: { biz_bot: '1' }
|
|
526
|
+
};
|
|
527
|
+
const resultBotNode = filterBotNode(additionalNodes);
|
|
528
|
+
if (resultBotNode && additionalNodes && additionalNodes.length > 0) {
|
|
529
|
+
stanza.content.push(...resultBotNode);
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
stanza.content.push(botNode);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
if (message && message.listMessage) {
|
|
428
536
|
stanza.content.push({
|
|
429
537
|
tag: 'biz',
|
|
430
538
|
attrs: {},
|
|
431
539
|
content: [
|
|
432
540
|
{
|
|
433
|
-
tag:
|
|
434
|
-
attrs: getButtonArgs(message)
|
|
541
|
+
tag: 'list',
|
|
542
|
+
attrs: getButtonArgs(message)
|
|
435
543
|
}
|
|
436
544
|
]
|
|
437
545
|
});
|
|
@@ -442,6 +550,62 @@ const makeMessagesSocket = (config) => {
|
|
|
442
550
|
});
|
|
443
551
|
return msgId;
|
|
444
552
|
};
|
|
553
|
+
const filterNativeNode = (nodeContent) => {
|
|
554
|
+
if (Array.isArray(nodeContent)) {
|
|
555
|
+
return nodeContent.filter((item) => {
|
|
556
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
557
|
+
if (item.tag === 'biz' && ((_a = item === null || item === void 0 ? void 0 : item.content[0]) === null || _a === void 0 ? void 0 : _a.tag) === 'interactive' && ((_c = (_b = item === null || item === void 0 ? void 0 : item.content[0]) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c.type) === 'native_flow' && ((_e = (_d = item === null || item === void 0 ? void 0 : item.content[0]) === null || _d === void 0 ? void 0 : _d.content[0]) === null || _e === void 0 ? void 0 : _e.tag) === 'native_flow' && ((_h = (_g = (_f = item === null || item === void 0 ? void 0 : item.content[0]) === null || _f === void 0 ? void 0 : _f.content[0]) === null || _g === void 0 ? void 0 : _g.attrs) === null || _h === void 0 ? void 0 : _h.name) === 'quick_reply') {
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
return true;
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
return nodeContent;
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
const filterBotNode = (nodeContent) => {
|
|
568
|
+
if (Array.isArray(nodeContent)) {
|
|
569
|
+
return nodeContent.filter((item) => {
|
|
570
|
+
if (item.tag === 'bot' && item.attrs.biz_bot === '1') {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
return true;
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
return nodeContent;
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
const getTypeMessage = (msg) => {
|
|
581
|
+
if (msg.viewOnceMessage) {
|
|
582
|
+
return getTypeMessage(msg.viewOnceMessage.message);
|
|
583
|
+
}
|
|
584
|
+
else if (msg.viewOnceMessageV2) {
|
|
585
|
+
return getTypeMessage(msg.viewOnceMessageV2.message);
|
|
586
|
+
}
|
|
587
|
+
else if (msg.viewOnceMessageV2Extension) {
|
|
588
|
+
return getTypeMessage(msg.viewOnceMessageV2Extension.message);
|
|
589
|
+
}
|
|
590
|
+
else if (msg.ephemeralMessage) {
|
|
591
|
+
return getTypeMessage(msg.ephemeralMessage.message);
|
|
592
|
+
}
|
|
593
|
+
else if (msg.documentWithCaptionMessage) {
|
|
594
|
+
return getTypeMessage(msg.documentWithCaptionMessage.message);
|
|
595
|
+
}
|
|
596
|
+
else if (msg.reactionMessage) {
|
|
597
|
+
return 'reaction';
|
|
598
|
+
}
|
|
599
|
+
else if (msg.pollCreationMessage || msg.pollCreationMessageV2 || msg.pollCreationMessageV3 || msg.pollUpdateMessage) {
|
|
600
|
+
return 'poll';
|
|
601
|
+
}
|
|
602
|
+
else if (getMediaType(msg)) {
|
|
603
|
+
return 'media';
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
return 'text';
|
|
607
|
+
}
|
|
608
|
+
};
|
|
445
609
|
const getMediaType = (message) => {
|
|
446
610
|
if (message.imageMessage) {
|
|
447
611
|
return 'image';
|
|
@@ -485,22 +649,8 @@ const makeMessagesSocket = (config) => {
|
|
|
485
649
|
else if (message.interactiveResponseMessage) {
|
|
486
650
|
return 'native_flow_response';
|
|
487
651
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
if (message.buttonsMessage) {
|
|
491
|
-
return 'buttons';
|
|
492
|
-
}
|
|
493
|
-
else if (message.buttonsResponseMessage) {
|
|
494
|
-
return 'buttons_response';
|
|
495
|
-
}
|
|
496
|
-
else if (message.interactiveResponseMessage) {
|
|
497
|
-
return 'interactive_response';
|
|
498
|
-
}
|
|
499
|
-
else if (message.listMessage) {
|
|
500
|
-
return 'list';
|
|
501
|
-
}
|
|
502
|
-
else if (message.listResponseMessage) {
|
|
503
|
-
return 'list_response';
|
|
652
|
+
else if (message.groupInviteMessage) {
|
|
653
|
+
return 'url';
|
|
504
654
|
}
|
|
505
655
|
};
|
|
506
656
|
const getButtonArgs = (message) => {
|
|
@@ -557,6 +707,10 @@ const makeMessagesSocket = (config) => {
|
|
|
557
707
|
getButtonArgs,
|
|
558
708
|
readMessages,
|
|
559
709
|
refreshMediaConn,
|
|
710
|
+
getUSyncDevices,
|
|
711
|
+
sendPeerDataOperationMessage,
|
|
712
|
+
createParticipantNodes,
|
|
713
|
+
profilePictureUrl,
|
|
560
714
|
waUploadToServer,
|
|
561
715
|
fetchPrivacySettings,
|
|
562
716
|
updateMediaMessage: async (message) => {
|
|
@@ -576,7 +730,7 @@ const makeMessagesSocket = (config) => {
|
|
|
576
730
|
else {
|
|
577
731
|
try {
|
|
578
732
|
const media = (0, Utils_1.decryptMediaRetryData)(result.media, mediaKey, result.key.id);
|
|
579
|
-
if (media.result !== WAProto_1.proto.MediaRetryNotification.ResultType.SUCCESS) {
|
|
733
|
+
if (media && media.result !== WAProto_1.proto.MediaRetryNotification.ResultType.SUCCESS) {
|
|
580
734
|
const resultStr = WAProto_1.proto.MediaRetryNotification.ResultType[media.result];
|
|
581
735
|
throw new boom_1.Boom(`Media re-upload failed by device (${resultStr})`, { data: media, statusCode: (0, Utils_1.getStatusCodeForMediaRetry)(media.result) || 404 });
|
|
582
736
|
}
|
|
@@ -600,8 +754,167 @@ const makeMessagesSocket = (config) => {
|
|
|
600
754
|
]);
|
|
601
755
|
return message;
|
|
602
756
|
},
|
|
757
|
+
sendStatusMentions: async (content, jids = []) => {
|
|
758
|
+
const userJid = (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id);
|
|
759
|
+
let allUsers = [];
|
|
760
|
+
for (const id of jids) {
|
|
761
|
+
const { user, server } = (0, WABinary_1.jidDecode)(id);
|
|
762
|
+
const isGroup = server === 'g.us';
|
|
763
|
+
const isPrivate = server === 's.whatsapp.net';
|
|
764
|
+
if (isGroup) {
|
|
765
|
+
let userId = await groupMetadata(id);
|
|
766
|
+
let participant = await userId.participants;
|
|
767
|
+
let users = await Promise.all(participant.map(u => (0, WABinary_1.jidNormalizedUser)(u.id)));
|
|
768
|
+
allUsers = [...allUsers, ...users];
|
|
769
|
+
}
|
|
770
|
+
else if (isPrivate) {
|
|
771
|
+
let users = await Promise.all(jids.map(id => id.replace(/\b\d{18}@.{4}\b/g, '')));
|
|
772
|
+
allUsers = [...allUsers, ...users];
|
|
773
|
+
}
|
|
774
|
+
if (!allUsers.find(user => user.includes(userJid))) {
|
|
775
|
+
allUsers.push(userJid);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
;
|
|
779
|
+
const getRandomHexColor = () => {
|
|
780
|
+
return "#" + Math.floor(Math.random() * 16777215)
|
|
781
|
+
.toString(16)
|
|
782
|
+
.padStart(6, "0");
|
|
783
|
+
};
|
|
784
|
+
let mediaHandle;
|
|
785
|
+
let msg = await (0, Utils_1.generateWAMessage)(WABinary_1.STORIES_JID, content, {
|
|
786
|
+
logger,
|
|
787
|
+
userJid,
|
|
788
|
+
getUrlInfo: text => (0, link_preview_1.getUrlInfo)(text, {
|
|
789
|
+
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
790
|
+
fetchOpts: {
|
|
791
|
+
timeout: 3000,
|
|
792
|
+
...axiosOptions || {}
|
|
793
|
+
},
|
|
794
|
+
logger,
|
|
795
|
+
uploadImage: generateHighQualityLinkPreview
|
|
796
|
+
? waUploadToServer
|
|
797
|
+
: undefined
|
|
798
|
+
}),
|
|
799
|
+
upload: async (readStream, opts) => {
|
|
800
|
+
const up = await waUploadToServer(readStream, { ...opts });
|
|
801
|
+
mediaHandle = up.handle;
|
|
802
|
+
return up;
|
|
803
|
+
},
|
|
804
|
+
mediaCache: config.mediaCache,
|
|
805
|
+
options: config.options,
|
|
806
|
+
backgroundColor: getRandomHexColor(),
|
|
807
|
+
font: Math.floor(Math.random() * 9),
|
|
808
|
+
});
|
|
809
|
+
await relayMessage(WABinary_1.STORIES_JID, msg.message, {
|
|
810
|
+
messageId: msg.key.id,
|
|
811
|
+
statusJidList: allUsers,
|
|
812
|
+
additionalNodes: [
|
|
813
|
+
{
|
|
814
|
+
tag: 'meta',
|
|
815
|
+
attrs: {},
|
|
816
|
+
content: [
|
|
817
|
+
{
|
|
818
|
+
tag: 'mentioned_users',
|
|
819
|
+
attrs: {},
|
|
820
|
+
content: jids.map(jid => ({
|
|
821
|
+
tag: 'to',
|
|
822
|
+
attrs: { jid },
|
|
823
|
+
content: undefined,
|
|
824
|
+
})),
|
|
825
|
+
},
|
|
826
|
+
],
|
|
827
|
+
},
|
|
828
|
+
],
|
|
829
|
+
});
|
|
830
|
+
jids.forEach(async (id) => {
|
|
831
|
+
id = (0, WABinary_1.jidNormalizedUser)(id);
|
|
832
|
+
const { user, server } = (0, WABinary_1.jidDecode)(id);
|
|
833
|
+
const isPrivate = server === 's.whatsapp.net';
|
|
834
|
+
let type = isPrivate
|
|
835
|
+
? 'statusMentionMessage'
|
|
836
|
+
: 'groupStatusMentionMessage';
|
|
837
|
+
await relayMessage(id, {
|
|
838
|
+
[type]: {
|
|
839
|
+
message: {
|
|
840
|
+
protocolMessage: {
|
|
841
|
+
key: msg.key,
|
|
842
|
+
type: 25,
|
|
843
|
+
},
|
|
844
|
+
},
|
|
845
|
+
},
|
|
846
|
+
}, {});
|
|
847
|
+
await (0, Utils_1.delay)(2500);
|
|
848
|
+
});
|
|
849
|
+
return msg;
|
|
850
|
+
},
|
|
851
|
+
sendAlbumMessage: async (jid, medias, options = {}) => {
|
|
852
|
+
const userJid = authState.creds.me.id;
|
|
853
|
+
for (const media of medias) {
|
|
854
|
+
if (!media.image && !media.video)
|
|
855
|
+
throw new TypeError(`medias[i] must have image or video property`);
|
|
856
|
+
}
|
|
857
|
+
if (medias.length < 2)
|
|
858
|
+
throw new RangeError("Minimum 2 media");
|
|
859
|
+
const time = options.delay || 500;
|
|
860
|
+
delete options.delay;
|
|
861
|
+
const album = await (0, Utils_1.generateWAMessageFromContent)(jid, {
|
|
862
|
+
albumMessage: {
|
|
863
|
+
expectedImageCount: medias.filter(media => media.image).length,
|
|
864
|
+
expectedVideoCount: medias.filter(media => media.video).length,
|
|
865
|
+
...options
|
|
866
|
+
}
|
|
867
|
+
}, { userJid, ...options });
|
|
868
|
+
await relayMessage(jid, album.message, { messageId: album.key.id });
|
|
869
|
+
let mediaHandle;
|
|
870
|
+
let msg;
|
|
871
|
+
for (const i in medias) {
|
|
872
|
+
const media = medias[i];
|
|
873
|
+
if (media.image) {
|
|
874
|
+
msg = await (0, Utils_1.generateWAMessage)(jid, {
|
|
875
|
+
image: media.image,
|
|
876
|
+
...media,
|
|
877
|
+
...options
|
|
878
|
+
}, {
|
|
879
|
+
userJid,
|
|
880
|
+
upload: async (readStream, opts) => {
|
|
881
|
+
const up = await waUploadToServer(readStream, { ...opts, newsletter: (0, WABinary_1.isJidNewsLetter)(jid) });
|
|
882
|
+
mediaHandle = up.handle;
|
|
883
|
+
return up;
|
|
884
|
+
},
|
|
885
|
+
...options,
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
else if (media.video) {
|
|
889
|
+
msg = await (0, Utils_1.generateWAMessage)(jid, {
|
|
890
|
+
video: media.video,
|
|
891
|
+
...media,
|
|
892
|
+
...options
|
|
893
|
+
}, {
|
|
894
|
+
userJid,
|
|
895
|
+
upload: async (readStream, opts) => {
|
|
896
|
+
const up = await waUploadToServer(readStream, { ...opts, newsletter: (0, WABinary_1.isJidNewsLetter)(jid) });
|
|
897
|
+
mediaHandle = up.handle;
|
|
898
|
+
return up;
|
|
899
|
+
},
|
|
900
|
+
...options,
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
if (msg) {
|
|
904
|
+
msg.message.messageContextInfo = {
|
|
905
|
+
messageAssociation: {
|
|
906
|
+
associationType: 1,
|
|
907
|
+
parentMessageKey: album.key
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
await relayMessage(jid, msg.message, { messageId: msg.key.id });
|
|
912
|
+
await (0, Utils_1.delay)(time);
|
|
913
|
+
}
|
|
914
|
+
return album;
|
|
915
|
+
},
|
|
603
916
|
sendMessage: async (jid, content, options = {}) => {
|
|
604
|
-
var _a, _b;
|
|
917
|
+
var _a, _b, _c;
|
|
605
918
|
const userJid = authState.creds.me.id;
|
|
606
919
|
if (typeof content === 'object' &&
|
|
607
920
|
'disappearingMessagesInChat' in content &&
|
|
@@ -614,9 +927,25 @@ const makeMessagesSocket = (config) => {
|
|
|
614
927
|
await groupToggleEphemeral(jid, value);
|
|
615
928
|
}
|
|
616
929
|
else {
|
|
930
|
+
let mediaHandle;
|
|
931
|
+
const { server } = (0, WABinary_1.jidDecode)(jid);
|
|
932
|
+
const isGroup = server === 'g.us';
|
|
933
|
+
let eph;
|
|
934
|
+
if (isGroup) {
|
|
935
|
+
const disappearingNode = await groupQuery(jid, 'get', [
|
|
936
|
+
{
|
|
937
|
+
tag: 'query',
|
|
938
|
+
attrs: { request: 'interactive' }
|
|
939
|
+
}
|
|
940
|
+
]);
|
|
941
|
+
const group = (0, WABinary_1.getBinaryNodeChild)(disappearingNode, 'group');
|
|
942
|
+
const expiration = (0, WABinary_1.getBinaryNodeChild)(group, 'ephemeral');
|
|
943
|
+
eph = (_a = expiration === null || expiration === void 0 ? void 0 : expiration.attrs) === null || _a === void 0 ? void 0 : _a.expiration;
|
|
944
|
+
}
|
|
617
945
|
const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
|
|
618
946
|
logger,
|
|
619
947
|
userJid,
|
|
948
|
+
ephemeralExpiration: (options.ephemeralExpiration && options.ephemeralExpiration > 0) ? options.ephemeralExpiration : eph,
|
|
620
949
|
getUrlInfo: text => (0, link_preview_1.getUrlInfo)(text, {
|
|
621
950
|
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
622
951
|
fetchOpts: {
|
|
@@ -628,18 +957,27 @@ const makeMessagesSocket = (config) => {
|
|
|
628
957
|
? waUploadToServer
|
|
629
958
|
: undefined
|
|
630
959
|
}),
|
|
631
|
-
upload:
|
|
960
|
+
upload: async (readStream, opts) => {
|
|
961
|
+
const up = await waUploadToServer(readStream, { ...opts, newsletter: (0, WABinary_1.isJidNewsLetter)(jid) });
|
|
962
|
+
mediaHandle = up.handle;
|
|
963
|
+
return up;
|
|
964
|
+
},
|
|
632
965
|
mediaCache: config.mediaCache,
|
|
633
966
|
options: config.options,
|
|
634
967
|
...options,
|
|
635
968
|
});
|
|
636
|
-
const
|
|
969
|
+
const isAiMsg = 'ai' in content && !!content.ai;
|
|
970
|
+
const isPinMsg = 'pin' in content && !!content.pin;
|
|
971
|
+
const isKeepMsg = 'keep' in content && content.keep;
|
|
972
|
+
const isPollMsg = 'poll' in content && !!content.poll;
|
|
637
973
|
const isEditMsg = 'edit' in content && !!content.edit;
|
|
974
|
+
const isDeleteMsg = 'delete' in content && !!content.delete;
|
|
638
975
|
const additionalAttributes = {};
|
|
976
|
+
const additionalNodes = [];
|
|
639
977
|
// required for delete
|
|
640
978
|
if (isDeleteMsg) {
|
|
641
979
|
// if the chat is a group, and I am not the author, then delete the message as an admin
|
|
642
|
-
if ((0, WABinary_1.isJidGroup)((
|
|
980
|
+
if (((0, WABinary_1.isJidGroup)((_b = content.delete) === null || _b === void 0 ? void 0 : _b.remoteJid) && !((_c = content.delete) === null || _c === void 0 ? void 0 : _c.fromMe)) || (0, WABinary_1.isJidNewsLetter)(jid)) {
|
|
643
981
|
additionalAttributes.edit = '8';
|
|
644
982
|
}
|
|
645
983
|
else {
|
|
@@ -647,9 +985,29 @@ const makeMessagesSocket = (config) => {
|
|
|
647
985
|
}
|
|
648
986
|
}
|
|
649
987
|
else if (isEditMsg) {
|
|
650
|
-
additionalAttributes.edit = '1';
|
|
988
|
+
additionalAttributes.edit = (0, WABinary_1.isJidNewsLetter)(jid) ? '3' : '1';
|
|
989
|
+
}
|
|
990
|
+
else if (isPinMsg) {
|
|
991
|
+
additionalAttributes.edit = '2';
|
|
992
|
+
}
|
|
993
|
+
else if (isAiMsg) {
|
|
994
|
+
additionalNodes.push({
|
|
995
|
+
attrs: {
|
|
996
|
+
biz_bot: '1'
|
|
997
|
+
},
|
|
998
|
+
tag: 'bot'
|
|
999
|
+
});
|
|
1000
|
+
if (options.additionalNodes) {
|
|
1001
|
+
additionalNodes.push(...options.additionalNodes);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
if (mediaHandle) {
|
|
1005
|
+
additionalAttributes['media_id'] = mediaHandle;
|
|
1006
|
+
}
|
|
1007
|
+
if ('cachedGroupMetadata' in options) {
|
|
1008
|
+
console.warn('cachedGroupMetadata in sendMessage are deprecated, now cachedGroupMetadata is part of the socket config.');
|
|
651
1009
|
}
|
|
652
|
-
await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id, cachedGroupMetadata: options.cachedGroupMetadata, additionalAttributes, statusJidList: options.statusJidList });
|
|
1010
|
+
await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id, cachedGroupMetadata: options.cachedGroupMetadata, additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes, additionalAttributes, statusJidList: options.statusJidList });
|
|
653
1011
|
if (config.emitOwnEvents) {
|
|
654
1012
|
process.nextTick(() => {
|
|
655
1013
|
processingMutex.mutex(() => (upsertMessage(fullMsg, 'append')));
|