Enhance user description synchronization with Telegram profile

- Added functionality to update user descriptions on the panel during synchronization, incorporating Telegram fields such as username, first name, and last name.
- Implemented error handling and logging for failed description updates in both admin sync and profile sync processes.
- Updated user creation and details update methods in the subscription service to include user descriptions, improving consistency across user data management.
This commit is contained in:
machka-pasla
2025-08-29 11:05:21 +03:00
parent e6b3a7c66f
commit f4730c3ceb
3 changed files with 75 additions and 1 deletions
+17
View File
@@ -136,6 +136,23 @@ async def perform_sync(panel_service: PanelApiService, session: AsyncSession,
users_uuid_updated += 1
logging.info(f"Updated panel UUID for user {actual_user_id}: {panel_uuid}")
# Ensure panel description contains Telegram fields
try:
if panel_uuid and existing_user:
description_text = "\n".join([
existing_user.username or "",
existing_user.first_name or "",
existing_user.last_name or "",
])
if description_text.strip():
await panel_service.update_user_details_on_panel(
panel_uuid, {"description": description_text}
)
except Exception as e_desc:
logging.warning(
f"Sync: Failed to update description for panel user {panel_uuid} (tg {actual_user_id}): {e_desc}"
)
# Sync subscription data
panel_expire_at_iso = panel_user_dict.get("expireAt")
panel_status = panel_user_dict.get("status", "UNKNOWN")