feat: implement multi-line session failover with round-robin strategy and session readiness validation for OTP delivery.

This commit is contained in:
Hamza-Ayed
2026-08-29 22:11:10 +03:00
parent f9609b4403
commit aec9fcee72
4 changed files with 154 additions and 62 deletions
+12 -2
View File
@@ -20,7 +20,7 @@ for (const p of envPaths) {
const express = require('express');
const cors = require('cors');
const { startSession, disconnectSession, sendMessage, getActiveSessions, checkContact, exportChatHistory, throttleManager } = require('./baileys-client');
const { startSession, disconnectSession, sendMessage, getActiveSessions, isSessionReady, checkContact, exportChatHistory, throttleManager } = require('./baileys-client');
const app = express();
app.use(cors());
@@ -79,7 +79,17 @@ app.post('/api/sessions/disconnect', async (req, res) => {
// Get list of active session keys in memory
app.get('/api/sessions/active', (req, res) => {
res.json({ status: 'success', active_sessions: getActiveSessions() });
const active = getActiveSessions();
const readySessions = active.filter(key => isSessionReady(key));
res.json({
status: 'success',
active_sessions: active,
ready_sessions: readySessions,
details: active.map(key => ({
session_key: key,
ready: isSessionReady(key)
}))
});
});
// Get throttle queue status for all sessions (Anti-Ban monitoring)