Refactor username update logic in SubscriptionService to prevent overwriting Telegram usernames

- Removed the conditional logic that updated the local user's username with the panel username, ensuring that the Telegram username remains unchanged.
- Added a comment to clarify the purpose of the update, focusing on maintaining the linkage to the panel UUID.
This commit is contained in:
machka-pasla
2025-08-25 12:24:30 +03:00
parent c69f02f7c0
commit b23b75b72e
+2 -15
View File
@@ -232,23 +232,10 @@ class SubscriptionService:
"panel_user_uuid": actual_panel_uuid_from_api
}
if (
actual_panel_username_from_api
and actual_panel_username_from_api
!= panel_username_on_panel_standard
and (
db_user.username is None
or db_user.username != actual_panel_username_from_api
)
):
update_data_for_local_user["username"] = (
actual_panel_username_from_api
)
# Do not overwrite Telegram username with panel username.
# Only update the local linkage to panel UUID here.
await user_dal.update_user(session, user_id, update_data_for_local_user)
db_user.panel_user_uuid = actual_panel_uuid_from_api
if "username" in update_data_for_local_user:
db_user.username = update_data_for_local_user["username"]
panel_user_created_or_linked_now = True
current_local_panel_uuid = actual_panel_uuid_from_api
else: