Developer docs

18. Privacy rules and blocking

Every privacy key is a PrivacyRule (Telegram InputPrivacyRule): a base (RULE_EVERYBODY, RULE_CONTACTS, RULE_NOBODY) plus exceptions: allow_users / allow_chats (“always allow”) and disallow_users / disallow_chats (“never allow”). The *_chats entries are groups or channels the owner is an active member of (checked on SetPrivacy, else CHAT_ID_INVALID), and their current active members match. Lists hold up to 1000 users and 100 chats (PRIVACY_TOO_LONG).

Evaluation (server-side, one function: service/privacy.go decide), for viewer V and owner O:

  1. V = O: allowed.
  2. O blocked V: denied for every key.
  3. A premium-only key whose owner isn’t premium: allowed (the rule is dormant).
  4. V in disallow_users, or a member of a disallow_chats chat: denied. “Never” beats “always”, also when the “always” match is a direct user entry.
  5. V in allow_users, or a member of an allow_chats chat: allowed.
  6. Base: everybody → allowed; contacts → allowed iff O has V in O’s contacts; nobody → denied.

Keys

Key (PrivacySettings)Legacy enumValuesPremiumEnforced in
last_seen_rulelast_seenall basesreciprocity exemption (last_seen perk)users() presence, presence push, GetReadParticipants
profile_photo_ruleprofile_photoall–users(): denied → the fallback photo, if any
phone_rulephoneall (default contacts)–users()
phone_discovery_rulephone_discoveryeverybody / contacts (default contacts)–UsersService/ResolvePhone
forwards_ruleforwardsall–ForwardMessages (evaluated for the forwarder; denied → ForwardInfo.from_name only)
calls_rulecallsall–RequestCall → USER_PRIVACY_RESTRICTED
calls_p2p_rule–all (default contacts)–CallJoinInfo.p2p_allowed
group_invites_rulegroup_invitesall–CreateGroup / AddMembers (groups and channels) → USER_PRIVACY_RESTRICTED
voice_messages_rule–all; non-everybody needs Premium (voice_privacy)yesevery posting path (send, album, forward, scheduled, web app, Bot API) in private chats → 403 VOICE_MESSAGES_FORBIDDEN
bio_rule–all–users()
gifts_rule–all–Server.CanSeeGifts (profile gift list)
new_chats (+ message_price_stars, new_chats_allow_users)–everybody / contacts and premium / paidyes (message_privacy)SendMessage (PRIVACY_PREMIUM_REQUIRED, PAYMENT_REQUIRED, §17)
hide_read_time–boolreciprocity exemptionGetReadParticipants

Compatibility. GetPrivacy returns both forms. In SetPrivacy a present *_rule wins, except that a legacy enum changed against a rule left at the stored base changes the base (a client that read the settings and edited only the enum). When *_rule is absent the legacy enum sets the base and the stored exceptions stay; keys without a legacy enum keep their stored rule.

Last seen. V sees O’s exact status (online / exact time) iff O’s rule allows V and either V’s own rule allows O or V is premium; otherwise an approximation (recently / last week / last month). Presence changes are pushed only to private-chat peers that may see them exactly; nobody else gets the update (no timing leak). A user who blocked V shows no presence at all (STATUS_UNSPECIFIED, “last seen a long time ago”).

Hide read time. Hides O’s read time from the people O hides their last seen from, and reciprocally hides theirs from O unless O is premium. Applies to private-chat read times and the “Seen by” list.

Fallback (“public”) photo. SetProfilePhoto{file_id, fallback: true} sets it (empty file_id removes it). Viewers the photo rule denies get it as User.photo; the owner sees it as User.fallback_photo. Blocked viewers get no photo.

Peer-to-peer. Media of every call (private ones included) goes through the LiveKit SFU, so a peer never learns the other’s IP address whatever the setting; TURN only hides the client from the SFU’s network path. CallJoinInfo.p2p_allowed reports whether both sides’ calls_p2p_rule allow each other so that a future direct mode can honour it; clients must not attempt a direct path while it is false.

Find by number. UsersService/ResolvePhone(phone): an unknown, deleted, bot or hidden number is the same 404 PHONE_NOT_OCCUPIED. 50 lookups per hour per user (plus 1/s).

Blocking matrix (A blocked B):

B triesResult
see A’s photo, phone, bio, presencehidden; presence = “a long time ago”; no presence pushes
message A in their private chat403 USER_IS_BLOCKED (A: YOU_BLOCKED_USER)
typing / emoji interactions in the private chatdropped silently, both directions
react in the private chat403 USER_IS_BLOCKED (A: YOU_BLOCKED_USER)
call A403 USER_PRIVACY_RESTRICTED (the block stays hidden); A calling B: YOU_BLOCKED_USER
secret chat, claim A’s keysUSER_IS_BLOCKED; GetDevices(A) is empty
add A to a group or channelUSER_PRIVACY_RESTRICTED
post in a group both are inworks both ways; messages stay visible to both

GetDevices of another user returns keys only (no device names unless the owner has the caller in contacts, no activity order) and is limited to 10/s per caller.

Generated from docs/PROTOCOL.md in the Telvoro repository. Wire names such as televo.v1 are unchanged.