Skip to content

Conversation

Copy link

Copilot AI commented Aug 18, 2025

Problem

In Telegram Desktop, when a user has a contact saved in their address book, the local contact name overrides the real first_name and last_name received from the Telegram API. This makes it impossible to access the original names from the API, even though they are still stored internally.

For example:

  • API returns: first_name="John", last_name="Smith"
  • Local contact: "Johnny D"
  • Current behavior: user->name() and user->topBarNameText() return "Johnny D"
  • Issue: No way to access the original "John Smith" from the API

Solution

Added three new methods to the UserData class that provide direct access to the original names from the Telegram API:

  • realFirstName() - Returns the original firstName field from Telegram API
  • realLastName() - Returns the original lastName field from Telegram API
  • realFullName() - Returns the formatted full name without contact overrides

Additionally, implemented a new enhanced setting "Show original name of contacts" that, when enabled, displays the original names from the Telegram API instead of local contact overrides throughout the entire client interface.

Enhanced Setting Features

When the "Show original name of contacts" setting is enabled:

  • Universal application: Affects all places where user names are displayed
  • Contacts list: Shows real names instead of saved contact names
  • Message views: Displays original API names in chat conversations
  • User profiles: Shows real names in profile dialogs
  • Search results: Returns matches based on original names
  • Top bar: Displays real names in chat headers
  • Any other UI element: Consistently shows original names everywhere

Usage Example

UserData* user = /* ... */;

// Access real names (bypass contact overrides) - always available
QString realFirst = user->realFirstName();    // "John" (from API)
QString realLast = user->realLastName();      // "Smith" (from API)
QString realFull = user->realFullName();      // "John Smith" (from API)

// Display names respect the enhanced setting
QString displayName = user->name();           // "John Smith" if setting enabled, "Johnny D" if disabled
QString topBarName = user->topBarNameText();  // "John Smith" if setting enabled, "Johnny D" if disabled

Implementation Details

  • Low-level integration: Modified PeerData::name() and PeerData::topBarNameText() methods to check the enhanced setting
  • Minimal overhead: Only performs additional checks when the setting is enabled
  • No breaking changes: All existing functionality is preserved when setting is disabled
  • Consistent behavior: Uses the same formatting logic as existing name methods
  • Enhanced settings integration: Follows established patterns for 64Gram settings

The implementation provides both programmatic access to real names via the new methods and a user-facing setting to globally switch the display behavior, giving users full control over how contact names are shown throughout the application.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Revincx Revincx marked this pull request as ready for review August 18, 2025 04:49
@Revincx Revincx marked this pull request as draft August 18, 2025 04:51
Co-authored-by: Revincx <25524750+Revincx@users.noreply.github.com>
Copilot AI changed the title [WIP] Try to find a way to get the real first_name and last_name of a contact. In current tdesktop or tdlib, the contact names will be override be the user settings, even if the tlapi will return overrided names. Add methods to access real user names without contact overrides Aug 18, 2025
Copilot AI requested a review from Revincx August 18, 2025 05:04
@Revincx
Copy link
Owner

Revincx commented Aug 18, 2025

@copilot Add a new option to enhanced settings: Show original name of contacts. If enabled, the client will always display the original name of contact users instead of the overrided names in any place, such as contacts box, message views, user profile box or any other possible place. (Just implement this feature on the low api level)

Co-authored-by: Revincx <25524750+Revincx@users.noreply.github.com>
Copy link
Author

Copilot AI commented Aug 18, 2025

@copilot Add a new option to enhanced settings: Show original name of contacts. If enabled, the client will always display the original name of contact users instead of the overrided names in any plac...

I've implemented the requested enhanced setting "Show original name of contacts". When enabled, this setting displays the original names from the Telegram API instead of local contact overrides throughout the client.

Implementation details:

  • Added show_original_name_of_contacts boolean setting to the enhanced settings system
  • Added UI toggle in the enhanced settings "Others" section
  • Modified the low-level PeerData::name() and PeerData::topBarNameText() methods to respect this setting
  • This affects all places where user names are displayed: contacts box, message views, user profile box, search results, dialogs, etc.

The implementation leverages the existing realFirstName(), realLastName(), and realFullName() methods I added earlier to access the original API names without contact overrides.

Commit: 49fc101

Copilot AI changed the title Add methods to access real user names without contact overrides Add methods to access real user names and enhanced setting to show original contact names Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants