Deploy: 2026-05-23 22:54:24
This commit is contained in:
@@ -20,7 +20,7 @@ for (const p of envPaths) {
|
||||
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const { startSession, disconnectSession, sendMessage, getActiveSessions, checkContact } = require('./baileys-client');
|
||||
const { startSession, disconnectSession, sendMessage, getActiveSessions, checkContact, exportChatHistory } = require('./baileys-client');
|
||||
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
@@ -99,6 +99,28 @@ app.post('/api/contacts/check', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Export chat history to file
|
||||
app.post('/api/chats/export', async (req, res) => {
|
||||
const { session_key } = req.body;
|
||||
|
||||
if (!session_key) {
|
||||
return res.status(400).json({ error: 'Missing session_key' });
|
||||
}
|
||||
|
||||
try {
|
||||
const filePath = await exportChatHistory(session_key);
|
||||
res.json({
|
||||
status: 'success',
|
||||
message: 'Chat history exported successfully',
|
||||
file_name: 'whatsapp_chats_history.txt',
|
||||
path: filePath
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(`Error exporting chats for session ${session_key}:`, err);
|
||||
res.status(500).json({ error: err.message || 'Failed to export chats' });
|
||||
}
|
||||
});
|
||||
|
||||
// Send outbound message
|
||||
app.post('/api/messages/send', async (req, res) => {
|
||||
const { session_key, phone, message, media_url, audio, mimetype, image } = req.body;
|
||||
|
||||
Reference in New Issue
Block a user