@raevon/n8n-nodes-whatsapp 2.0.14 → 2.0.15
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.
|
@@ -329,6 +329,18 @@ async function startServer(cfg) {
|
|
|
329
329
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
330
330
|
res.end(JSON.stringify({ success: true, message: 'Signed out' }));
|
|
331
331
|
}
|
|
332
|
+
else if (url.pathname === '/shutdown') {
|
|
333
|
+
if (state.socket) {
|
|
334
|
+
try {
|
|
335
|
+
state.socket.end(new Error('Shutdown'));
|
|
336
|
+
}
|
|
337
|
+
catch { }
|
|
338
|
+
}
|
|
339
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
340
|
+
res.end(JSON.stringify({ success: true }));
|
|
341
|
+
// Close HTTP server after sending response
|
|
342
|
+
setTimeout(() => { httpServer.close(); servers.delete(port); }, 500);
|
|
343
|
+
}
|
|
332
344
|
else {
|
|
333
345
|
res.writeHead(404);
|
|
334
346
|
res.end('Not found');
|
|
@@ -374,9 +386,9 @@ async function startServerIfNeeded(cfg) {
|
|
|
374
386
|
}
|
|
375
387
|
async function stopServer(cfg) {
|
|
376
388
|
const port = getPort(cfg);
|
|
377
|
-
// Try
|
|
389
|
+
// Try to shut down the server via /shutdown endpoint
|
|
378
390
|
try {
|
|
379
|
-
await fetch(`http://127.0.0.1:${port}/
|
|
391
|
+
await fetch(`http://127.0.0.1:${port}/shutdown`, { method: 'POST', signal: AbortSignal.timeout(3000) });
|
|
380
392
|
}
|
|
381
393
|
catch { }
|
|
382
394
|
// Clean up in-memory state
|
|
@@ -61,9 +61,8 @@ class WhatsAppConnect {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
else if (operation === 'stopServer') {
|
|
64
|
-
// Try graceful shutdown via /signout
|
|
65
64
|
try {
|
|
66
|
-
await fetch(`${(0, WhatsAppApiHelper_1.getServerUrl)(cfg)}/
|
|
65
|
+
await fetch(`${(0, WhatsAppApiHelper_1.getServerUrl)(cfg)}/shutdown`, { method: 'POST', signal: AbortSignal.timeout(3000) });
|
|
67
66
|
returnData.push({
|
|
68
67
|
json: { success: true, message: 'Server stopped', sessionPath: cfg.sessionPath },
|
|
69
68
|
pairedItem: { item: i },
|
|
@@ -71,7 +70,7 @@ class WhatsAppConnect {
|
|
|
71
70
|
}
|
|
72
71
|
catch {
|
|
73
72
|
returnData.push({
|
|
74
|
-
json: { success: false, message: '
|
|
73
|
+
json: { success: false, message: 'Could not reach server to stop it.', sessionPath: cfg.sessionPath },
|
|
75
74
|
pairedItem: { item: i },
|
|
76
75
|
});
|
|
77
76
|
}
|
package/package.json
CHANGED