natureco-cli 1.0.42 → 1.0.44
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/package.json
CHANGED
|
@@ -234,14 +234,35 @@ async function startWhatsAppProvider(sessionDir, config) {
|
|
|
234
234
|
log('whatsapp', `messages.upsert event triggered, ${messages.length} message(s)`, 'gray');
|
|
235
235
|
|
|
236
236
|
for (const msg of messages) {
|
|
237
|
-
|
|
237
|
+
// Log raw message info
|
|
238
|
+
log('whatsapp', `Raw message - fromMe: ${msg.key.fromMe}, remoteJid: ${msg.key.remoteJid}`, 'gray');
|
|
239
|
+
|
|
240
|
+
const remoteJid = msg.key.remoteJid || '';
|
|
241
|
+
const isLID = remoteJid.includes('@lid');
|
|
242
|
+
|
|
243
|
+
// Handle LID format (new WhatsApp format)
|
|
244
|
+
if (isLID) {
|
|
245
|
+
if (msg.key.fromMe) {
|
|
246
|
+
log('whatsapp', 'LID format detected, fromMe=true, accepting message', 'cyan');
|
|
247
|
+
} else {
|
|
248
|
+
log('whatsapp', 'LID format detected, fromMe=false, blocked', 'yellow');
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// If fromMe and LID, accept without further checks (own conversation)
|
|
254
|
+
if (msg.key.fromMe && isLID) {
|
|
255
|
+
log('whatsapp', 'Own conversation (fromMe + LID), processing...', 'cyan');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const sender = remoteJid.split('@')[0].split(':')[0];
|
|
238
259
|
const allowedNumbers = config.whatsappAllowedNumbers || [];
|
|
239
260
|
|
|
240
261
|
// Log incoming number before access control
|
|
241
262
|
log('whatsapp', `Incoming from: +${sender}, allowed: ${JSON.stringify(allowedNumbers)}`, 'gray');
|
|
242
263
|
|
|
243
|
-
// Access control - compare last 10 digits
|
|
244
|
-
if (allowedNumbers.length > 0 && !allowedNumbers.some(n => numberMatches(n, sender))) {
|
|
264
|
+
// Access control - compare last 10 digits (skip if fromMe + LID)
|
|
265
|
+
if (!(msg.key.fromMe && isLID) && allowedNumbers.length > 0 && !allowedNumbers.some(n => numberMatches(n, sender))) {
|
|
245
266
|
log('whatsapp', `blocked message from +${sender} (not in allowed list)`, 'yellow');
|
|
246
267
|
continue;
|
|
247
268
|
}
|