Refactor notification handling and streamline router registration

- Replaced legacy notification functions with a unified NotificationService for better maintainability and clarity.
- Updated the main bot router registration to utilize a root router, simplifying the inclusion of user and admin routes.
- Removed unused middleware and helper functions to enhance code cleanliness and focus on essential components.
- Improved localization by adding new error messages for user interactions.
This commit is contained in:
machka-pasla
2025-08-07 23:30:32 +03:00
parent 5853b9da63
commit 18f65ea493
13 changed files with 239 additions and 292 deletions
+7 -5
View File
@@ -7,7 +7,7 @@ from datetime import datetime, timezone
from config.settings import Settings
from bot.services.panel_api_service import PanelApiService
from bot.services.notification_service import notify_admin_panel_sync
from bot.services.notification_service import NotificationService
from db.dal import user_dal, subscription_dal, panel_sync_dal
@@ -287,8 +287,9 @@ async def sync_command_handler(
# Send notification to log channel with proper thread handling
try:
await notify_admin_panel_sync(
bot, settings, i18n, status, details,
notification_service = NotificationService(bot, settings, i18n)
await notification_service.notify_panel_sync(
status, details,
sync_result.get("users_processed", 0),
sync_result.get("subs_synced", 0)
)
@@ -301,8 +302,9 @@ async def sync_command_handler(
# Send notification to log channel about failure
try:
await notify_admin_panel_sync(
bot, settings, i18n, "failed", str(e_sync_global), 0, 0
notification_service = NotificationService(bot, settings, i18n)
await notification_service.notify_panel_sync(
"failed", str(e_sync_global), 0, 0
)
except Exception as e_notification:
logging.error(f"Failed to send sync failure notification: {e_notification}")