feat: implement multi-line session failover with round-robin strategy and session readiness validation for OTP delivery.
This commit is contained in:
@@ -804,11 +804,17 @@ function getActiveSessions() {
|
||||
return Array.from(sessions.keys());
|
||||
}
|
||||
|
||||
function isSessionReady(session_key) {
|
||||
const sock = sessions.get(session_key);
|
||||
return !!(sock && sock.user && sock.user.id);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
startSession,
|
||||
disconnectSession,
|
||||
sendMessage,
|
||||
getActiveSessions,
|
||||
isSessionReady,
|
||||
checkContact,
|
||||
exportChatHistory,
|
||||
throttleManager
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user