Deploy: 2026-05-23 23:28:20
This commit is contained in:
@@ -142,6 +142,22 @@ app.post('/api/messages/send', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Auto-resume existing sessions on startup
|
||||
const SESSIONS_DIR = path.join(__dirname, 'sessions');
|
||||
if (fs.existsSync(SESSIONS_DIR)) {
|
||||
const defaultWebhookUrl = process.env.WEBHOOK_URL || 'https://nabeh.intaleqapp.com/api/whatsapp/webhook';
|
||||
const activeSessions = fs.readdirSync(SESSIONS_DIR, { withFileTypes: true })
|
||||
.filter(dirent => dirent.isDirectory() && dirent.name.startsWith('cmp_'))
|
||||
.map(dirent => dirent.name);
|
||||
|
||||
for (const session_key of activeSessions) {
|
||||
console.log(`[Auto-Resume] Resuming session: ${session_key}`);
|
||||
startSession(session_key, defaultWebhookUrl).catch(err => {
|
||||
console.error(`[Auto-Resume] Failed to resume ${session_key}:`, err.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🚀 Nabeh WhatsApp Gateway running on port ${PORT}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user