export database

This commit is contained in:
Artyom Ashirov
2024-11-16 19:18:50 +03:00
parent 44ae5a6631
commit e3f2e87fcc
4 changed files with 947 additions and 14 deletions

View File

@@ -11,6 +11,7 @@ import AdminProductHandler from './handlers/adminProductHandler.js';
import ErrorHandler from './utils/errorHandler.js';
import User from './models/User.js';
import AdminUserLocationHandler from "./handlers/adminUserLocationHandler.js";
import AdminDumpHandler from "./handlers/adminDumpHandler.js";
// Debug logging function
const logDebug = (action, functionName) => {
@@ -39,6 +40,7 @@ const adminUserHandler = new AdminUserHandler(bot);
const adminLocationHandler = new AdminLocationHandler(bot);
const adminUserLocationHandler = new AdminUserLocationHandler(bot);
const adminProductHandler = new AdminProductHandler(bot);
const adminDumpHandler = new AdminDumpHandler(bot);
// Start command - Create user profile
bot.onText(/\/start/, async (msg) => {
@@ -135,6 +137,11 @@ bot.on('message', async (msg) => {
await adminLocationHandler.handleViewLocations(msg);
}
break;
case '💾 Database Backup':
if (adminHandler.isAdmin(msg.from.id)) {
await adminDumpHandler.handleDump(msg);
}
break;
}
} catch (error) {
await ErrorHandler.handleError(bot, msg.chat.id, error, 'message handler');
@@ -330,6 +337,12 @@ bot.on('callback_query', async (callbackQuery) => {
logDebug(action, 'handleEditUserDistrict');
await adminUserLocationHandler.handleEditUserDistrict(callbackQuery)
}
// Dump manage
else if (action === "export_database") {
await adminDumpHandler.exportDatabase(callbackQuery);
return;
}
await bot.answerCallbackQuery(callbackQuery.id);
} catch (error) {
await ErrorHandler.handleError(bot, msg.chat.id, error, 'callback query');