@dappaoffc/baileys-mod 5.0.6 → 5.0.7
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/Socket/socket.js +25 -14
- package/package.json +1 -1
package/lib/Socket/socket.js
CHANGED
|
@@ -210,27 +210,38 @@ export const makeSocket = (config) => {
|
|
|
210
210
|
const { creds } = authState;
|
|
211
211
|
const keys = addTransactionCapability(authState.keys, logger, transactionOpts);
|
|
212
212
|
const signalRepository = makeSignalRepository({ creds, keys }, logger, pnFromLIDUSync);
|
|
213
|
+
|
|
213
214
|
const toLid = async (pn) => {
|
|
214
|
-
if (pn
|
|
215
|
+
if (!pn) return "";
|
|
216
|
+
if (pn.includes("@lid")) return pn;
|
|
215
217
|
try {
|
|
216
|
-
|
|
218
|
+
return signalRepository.lidMapping.getLIDForPN(pn);
|
|
217
219
|
} catch (err) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
logger.error({ err }, "error jid unknown");
|
|
221
|
+
return pn;
|
|
220
222
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const toPn = async (pn) => {
|
|
226
|
+
if (!pn) return "";
|
|
227
|
+
if (
|
|
228
|
+
pn.includes("@s.whatsapp.net") ||
|
|
229
|
+
pn.includes("@g.us") ||
|
|
230
|
+
pn.includes("@newsletter")
|
|
231
|
+
) return pn;
|
|
232
|
+
|
|
224
233
|
try {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
234
|
+
const jid = await signalRepository.lidMapping.getPNForLID(pn);
|
|
235
|
+
if (!jid) return "";
|
|
236
|
+
const server = "@" + jid.split("@")[1];
|
|
237
|
+
const pN = jid.split(":")[0] + server;
|
|
238
|
+
return pN.toString();
|
|
229
239
|
} catch (err) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
240
|
+
logger.error({ err }, "error lid unknown");
|
|
241
|
+
return pn;
|
|
233
242
|
}
|
|
243
|
+
};
|
|
244
|
+
|
|
234
245
|
let lastDateRecv;
|
|
235
246
|
let epoch = 1;
|
|
236
247
|
let keepAliveReq;
|