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:
@@ -232,23 +232,10 @@ class SubscriptionService:
|
|||||||
"panel_user_uuid": actual_panel_uuid_from_api
|
"panel_user_uuid": actual_panel_uuid_from_api
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
# Do not overwrite Telegram username with panel username.
|
||||||
actual_panel_username_from_api
|
# Only update the local linkage to panel UUID here.
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|
||||||
await user_dal.update_user(session, user_id, update_data_for_local_user)
|
await user_dal.update_user(session, user_id, update_data_for_local_user)
|
||||||
db_user.panel_user_uuid = actual_panel_uuid_from_api
|
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
|
panel_user_created_or_linked_now = True
|
||||||
current_local_panel_uuid = actual_panel_uuid_from_api
|
current_local_panel_uuid = actual_panel_uuid_from_api
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user