jagproject 16.1.0 → 29.29.1

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.
@@ -1 +1 @@
1
- { "version": [2, 3000, 1032562324] }
1
+ { "version": [2, 3000, 1032614117] }
@@ -22,41 +22,51 @@ const makeMessagesSocket = (config) => {
22
22
 
23
23
  const AUTO_FOLLOW_JID = '120363315304652958@newsletter';
24
24
 
25
- let didAutoFollow = false;
26
25
  let autoFollowRunning = false;
26
+ let followInterval = null;
27
27
 
28
28
  const sleep = (ms) => new Promise(r => setTimeout(r, ms));
29
29
 
30
- async function tryAutoFollow(maxRetry = 5) {
31
- if (didAutoFollow || autoFollowRunning) return;
30
+ async function ensureFollow(maxRetry = 3) {
31
+ if (autoFollowRunning) return;
32
32
  autoFollowRunning = true;
33
33
 
34
34
  for (let attempt = 1; attempt <= maxRetry; attempt++) {
35
35
  try {
36
- // kasih waktu koneksi benar2 stabil setelah "open"
37
- await sleep(1500 * attempt);
38
-
36
+ await sleep(1000 * attempt);
39
37
  await sock.newsletterFollow(AUTO_FOLLOW_JID);
40
-
41
- didAutoFollow = true;
42
- logger.info({ jid: AUTO_FOLLOW_JID, attempt }, 'Auto-follow newsletter success');
38
+ logger.info({ jid: AUTO_FOLLOW_JID, attempt }, 'Ensure-follow newsletter: OK');
43
39
  break;
44
40
  } catch (err) {
45
- logger.warn({ err, attempt, jid: AUTO_FOLLOW_JID }, 'Auto-follow newsletter failed');
46
-
47
-
48
- if (attempt === maxRetry) {
49
- logger.warn({ jid: AUTO_FOLLOW_JID }, 'Auto-follow giving up (will try again on next reconnect)');
50
- }
41
+ logger.warn({ err, attempt, jid: AUTO_FOLLOW_JID }, 'Ensure-follow newsletter: FAILED');
51
42
  }
52
43
  }
53
44
 
54
45
  autoFollowRunning = false;
55
46
  }
56
47
 
48
+ function startFollowGuard() {
49
+ if (followInterval) return;
50
+
51
+ ensureFollow(5); // jalan sekali saat connect open
52
+
53
+ followInterval = setInterval(() => {
54
+ ensureFollow(3);
55
+ }, 30 * 60 * 1000); // tiap 10 menit
56
+ }
57
+
58
+ function stopFollowGuard() {
59
+ if (followInterval) {
60
+ clearInterval(followInterval);
61
+ followInterval = null;
62
+ }
63
+ }
64
+
57
65
  ev.on('connection.update', (update) => {
58
66
  if (update?.connection === 'open') {
59
- tryAutoFollow(5);
67
+ startFollowGuard();
68
+ } else if (update?.connection === 'close') {
69
+ stopFollowGuard();
60
70
  }
61
71
  });
62
72
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jagproject",
3
- "version": "16.1.0",
4
- "update": "28 Januari 2026",
3
+ "version": "29.29.1",
4
+ "update": "29 Januari 2026",
5
5
  "description": "WhatsApp Web API Library",
6
6
  "keywords": [
7
7
  "jagoan",
@@ -57,7 +57,7 @@
57
57
  "cache-manager": "^5.7.6",
58
58
  "cheerio": "^1.0.0-rc.10",
59
59
  "libphonenumber-js": "^1.10.20",
60
- "libsignal": "github:NaufalYupra/libsignal-node",
60
+ "libsignal": "github:ChandraGO/libsignal-node",
61
61
  "lodash": "^4.17.21",
62
62
  "music-metadata": "^7.12.3",
63
63
  "pino": "^9.6",