Skip to content

Telegram: Block does nothing, and there is no way to add, rename or remove a contact - #818

Closed
itz4blitz wants to merge 1 commit into
mainfrom
issue/487-telegram-block-contacts
Closed

itz4blitz wants to merge 1 commit into
mainfrom
issue/487-telegram-block-contacts

Conversation

@itz4blitz

Copy link
Copy Markdown
Collaborator

What changed and why

Block on a Telegram person now calls contacts.block and the person reads as blocked. Blocking someone who is already blocked calls contacts.unblock. Add and remove call contacts.addContact and contacts.deleteContacts. The blocked list is read at sign-on, and a block that arrives later is applied, without replacing the contact list.

Type

  • feature
  • fix
  • perf
  • refactor
  • chore
  • docs

Platforms

  • windows
  • macos
  • linux
  • android
  • ios

Proof

Scenario: e2e/scenarios/telegram-block-contact

Lab run:

Compatibility

No protocol change. An older client still has no unblock action, so a second block is what clears a block here. Friend requests are unchanged because Telegram has none.

Risk and rollback

A wrong block would hide that person from the contact list until they are unblocked. Revert this change.

Release note

Block, add and remove work for a Telegram contact, and a blocked person reads as blocked.

Tested with cargo test -p chatd --no-default-features on the scripted block, add, remove and block update, and with cargo clippy -p chatd --no-default-features --all-targets. No live Telegram account. The lab was not run.

Closes #487

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Tiny Code Review

⚠️ Code review unavailable · run

the AI provider rate-limited the request

This is advice, not a gate. Re-run with the agent:review label or a /review comment.

@unRekable unRekable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

🟡 1 finding (1 blocking).

Telegram gains a working Block (a second block unblocks, since RelateAction has no Unblock), contact add and remove, the blocked list read at sign-on, and updatePeerBlocked applied live. The state design holds: the blocked set lives in the per-connection Live, is rebuilt from contacts.getBlocked at sign-on and kept right by updates, and unknown state falls on the safe side. The defect is in Add: it hard-codes add_phone_privacy_exception, which puts the person on the user's phone-privacy exception list, so Telegram shows them the user's phone number from then on - the user never asked for that, and removing the contact later does not revoke it.

Residual risk

  • Past 500 blocked people the sign-on load stops (offset >= 500), so there the toggle infers the direction; it errs toward sending contacts.block, which Telegram keeps idempotent, so a block press cannot silently unblock someone whose state is unknown.
  • info.rs marks blocked one way only (userFull.blocked true); a person unblocked on another device while an updatePeerBlocked is lost in flight stays marked until the next reconnect rebuilds the set.
  • Re-adding a blocked person with Add flips their store relation to Contact while the block still stands on the network; the Blocked mark only returns at the next sign-on.

Comment thread crates/chatd/src/adapters/telegram.rs Outdated
let known = account.dir().get(who).cloned().unwrap_or_default();
let (first_name, last_name) = split_name(&known.name);
let answer = account.ask(&tl::functions::contacts::AddContact {
add_phone_privacy_exception: true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocker: This flag grants the added person lasting visibility of the user's phone number: Telegram's docs say to set it only when the user wishes to share it (first-party clients make it an explicit unchecked choice, and set it only when peerSettings.need_contacts_exception asks). Hard-coded true shares it on every Add, and contacts.deleteContacts does not undo the exception. Send false and leave the user's privacy setting as it is.

Suggested change
add_phone_privacy_exception: true,
add_phone_privacy_exception: false,

@itz4blitz
itz4blitz force-pushed the issue/487-telegram-block-contacts branch from 01e2cc0 to 81ea280 Compare November 17, 2026 22:31
@itz4blitz

Copy link
Copy Markdown
Collaborator Author

Superseded by and merged in #903 (d387971 — Release 2026-11-20 combined PR).

@itz4blitz itz4blitz closed this Nov 21, 2026
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.

Telegram: Block does nothing, and there is no way to add, rename or remove a contact

2 participants