astrabail 1.1.2 → 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.
@@ -921,9 +921,12 @@ const makeMessagesRecvSocket = (config) => {
921
921
  await sendMessageAck(node);
922
922
  return;
923
923
  }
924
- try {
925
- await Promise.all([
926
- notificationMutex.mutex(async () => {
924
+ // ✅ Kirim ACK segera ke WA server agar koneksi tidak dianggap timeout
925
+ // Proses notifikasi dilakukan di background via setImmediate — non-blocking
926
+ sendMessageAck(node).catch(err => onUnexpectedError(err, 'sending notification ack'));
927
+ setImmediate(async () => {
928
+ try {
929
+ await notificationMutex.mutex(async () => {
927
930
  const msg = await processNotification(node);
928
931
  if (msg) {
929
932
  const fromMe = (0, index_js_5.areJidsSameUser)(node.attrs.participant || remoteJid, authState.creds.me.id);
@@ -942,12 +945,12 @@ const makeMessagesRecvSocket = (config) => {
942
945
  const fullMsg = index_js_1.proto.WebMessageInfo.fromObject(msg);
943
946
  await upsertMessage(fullMsg, 'append');
944
947
  }
945
- })
946
- ]);
947
- }
948
- finally {
949
- await sendMessageAck(node);
950
- }
948
+ });
949
+ }
950
+ catch (err) {
951
+ onUnexpectedError(err, 'handling notification');
952
+ }
953
+ });
951
954
  };
952
955
  const resolveMentionedLIDs = async (msg, lidMapping) => {
953
956
  if (msg.key?.participant?.endsWith('@lid')) {
@@ -1581,8 +1584,15 @@ const makeMessagesRecvSocket = (config) => {
1581
1584
  /// and adds the task to the existing buffer if we're buffering events
1582
1585
  const processNodeWithBuffer = async (node, identifier, exec) => {
1583
1586
  ev.buffer();
1584
- await execTask();
1585
- ev.flush();
1587
+ try {
1588
+ await execTask();
1589
+ }
1590
+ finally {
1591
+ // Gunakan setImmediate agar event loop sempat memproses I/O lain
1592
+ // sebelum buffer di-flush — ini yang mencegah bot "stuck" saat ada user join
1593
+ await new Promise(resolve => setImmediate(resolve));
1594
+ ev.flush();
1595
+ }
1586
1596
  function execTask() {
1587
1597
  return exec(node, false).catch(err => onUnexpectedError(err, identifier));
1588
1598
  }
@@ -388,13 +388,24 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
388
388
  const jid = message.key?.remoteJid;
389
389
  //let actor = whatsappID (message.participant)
390
390
  let participants;
391
- const emitParticipantsUpdate = (action) => ev.emit('group-participants.update', {
392
- id: jid,
393
- author: message.key.participant,
394
- authorPn: message.key.participantAlt,
395
- participants,
396
- action
397
- });
391
+ const emitParticipantsUpdate = (action) => {
392
+ // Normalisasi LID → PN sebelum emit
393
+ // Jika id adalah LID dan phoneNumber tersedia, gunakan phoneNumber sebagai id
394
+ // Agar developer bot tidak perlu decode LID secara manual
395
+ const normalizedParticipants = (participants || []).map(p => {
396
+ if (p.id?.endsWith('@lid') && p.phoneNumber) {
397
+ return { ...p, id: p.phoneNumber, lid: p.id };
398
+ }
399
+ return p;
400
+ });
401
+ ev.emit('group-participants.update', {
402
+ id: jid,
403
+ author: message.key.participant,
404
+ authorPn: message.key.participantAlt,
405
+ participants: normalizedParticipants,
406
+ action
407
+ });
408
+ };
398
409
  const emitGroupUpdate = (update) => {
399
410
  ev.emit('groups.update', [
400
411
  { id: jid, ...update, author: message.key.participant ?? undefined, authorPn: message.key.participantAlt }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "astrabail",
3
- "version": "1.1.2",
4
- "update": "25 April 2026",
3
+ "version": "1.1.3",
4
+ "update": "26 April 2026",
5
5
  "description": "Professional Whatsapp Web API Library",
6
6
  "keywords": [
7
7
  "astra",