@kaels/casileys 0.4.5 → 0.4.6

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.
@@ -6,6 +6,7 @@ import { proto } from '../../WAProto/index.js';
6
6
  import { DEFAULT_CACHE_TTLS, KEY_BUNDLE_TYPE, MIN_PREKEY_COUNT, PLACEHOLDER_MAX_AGE_SECONDS, STATUS_EXPIRY_SECONDS } from '../Defaults/index.js';
7
7
  import { ReachoutTimelockEnforcementType, WAMessageStatus, WAMessageStubType } from '../Types/index.js';
8
8
  import { ACCOUNT_RESTRICTED_TEXT, aesDecryptCTR, aesEncryptGCM, cleanMessage, Curve, decodeMediaRetryNode, decodeMessageNode, decryptMessageNode, delay, derivePairingCodeKey, encodeBigEndian, encodeSignedDeviceIdentity, extractAddressingContext, extractE2ESessionFromRetryReceipt, getCallStatusFromNode, getHistoryMsg, getNextPreKeys, getStatusFromReceiptType, handleIdentityChange, hkdf, MISSING_KEYS_ERROR_TEXT, NACK_REASONS, NO_MESSAGE_FOUND_ERROR_TEXT, SERVER_ERROR_CODES, toNumber, unixTimestampSeconds, xmppPreKey, xmppSignedPreKey } from '../Utils/index.js';
9
+ import { getContentType, normalizeMessageContent } from '../Utils/messages.js';
9
10
  import { makeMutex } from '../Utils/make-mutex.js';
10
11
  import { makeOfflineNodeProcessor } from '../Utils/offline-node-processor.js';
11
12
  import { buildAckStanza } from '../Utils/stanza-ack.js';
@@ -1263,6 +1264,25 @@ export const makeMessagesRecvSocket = (config) => {
1263
1264
  await sendMessageAck(node).catch(ackErr => logger.error({ ackErr }, 'failed to ack notification'));
1264
1265
  }
1265
1266
  };
1267
+ const resolveMentionedPn = async (message) => {
1268
+ const content = normalizeMessageContent(message);
1269
+ const contentType = getContentType(content);
1270
+ const contextInfo = content?.[contentType]?.contextInfo;
1271
+
1272
+ if (!contextInfo?.mentionedJid?.length) return;
1273
+
1274
+ const lids = contextInfo.mentionedJid.filter(isLidUser);
1275
+ if (!lids.length) return;
1276
+
1277
+ const mappings =
1278
+ await signalRepository.lidMapping.getPNsForLIDs(lids);
1279
+
1280
+ contextInfo.mentionedPn = lids
1281
+ .map(lid => mappings.find(mapping => mapping.lid === lid)?.pn)
1282
+ .filter(Boolean)
1283
+ .map(pn => pn.replace(':0@', '@'));
1284
+ };
1285
+
1266
1286
  const handleMessage = async (node) => {
1267
1287
  const encNode = getBinaryNodeChild(node, 'enc');
1268
1288
  // TODO: temporary fix for crashes and issues resulting of failed msmsg decryption
@@ -1429,6 +1449,7 @@ export const makeMessagesRecvSocket = (config) => {
1429
1449
  }
1430
1450
  }
1431
1451
  cleanMessage(msg, authState.creds.me.id, authState.creds.me.lid);
1452
+ await resolveMentionedPn(msg.message);
1432
1453
  await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify');
1433
1454
  });
1434
1455
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaels/casileys",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Casileys — Enhanced WhatsApp Web API based on Baileys.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",