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:
- V = O: allowed.
- O blocked V: denied for every key.
- A premium-only key whose owner isn’t premium: allowed (the rule is dormant).
- V in
disallow_users, or a member of adisallow_chatschat: denied. “Never” beats “always”, also when the “always” match is a direct user entry. - V in
allow_users, or a member of anallow_chatschat: allowed. - Base: everybody → allowed; contacts → allowed iff O has V in O’s contacts; nobody → denied.
Keys
Key (PrivacySettings) | Legacy enum | Values | Premium | Enforced in |
|---|---|---|---|---|
last_seen_rule | last_seen | all bases | reciprocity exemption (last_seen perk) | users() presence, presence push, GetReadParticipants |
profile_photo_rule | profile_photo | all | – | users(): denied → the fallback photo, if any |
phone_rule | phone | all (default contacts) | – | users() |
phone_discovery_rule | phone_discovery | everybody / contacts (default contacts) | – | UsersService/ResolvePhone |
forwards_rule | forwards | all | – | ForwardMessages (evaluated for the forwarder; denied → ForwardInfo.from_name only) |
calls_rule | calls | all | – | RequestCall → USER_PRIVACY_RESTRICTED |
calls_p2p_rule | – | all (default contacts) | – | CallJoinInfo.p2p_allowed |
group_invites_rule | group_invites | all | – | CreateGroup / AddMembers (groups and channels) → USER_PRIVACY_RESTRICTED |
voice_messages_rule | – | all; non-everybody needs Premium (voice_privacy) | yes | every 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 / paid | yes (message_privacy) | SendMessage (PRIVACY_PREMIUM_REQUIRED, PAYMENT_REQUIRED, §17) |
hide_read_time | – | bool | reciprocity exemption | GetReadParticipants |
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 tries | Result |
|---|---|
| see A’s photo, phone, bio, presence | hidden; presence = “a long time ago”; no presence pushes |
| message A in their private chat | 403 USER_IS_BLOCKED (A: YOU_BLOCKED_USER) |
| typing / emoji interactions in the private chat | dropped silently, both directions |
| react in the private chat | 403 USER_IS_BLOCKED (A: YOU_BLOCKED_USER) |
| call A | 403 USER_PRIVACY_RESTRICTED (the block stays hidden); A calling B: YOU_BLOCKED_USER |
| secret chat, claim A’s keys | USER_IS_BLOCKED; GetDevices(A) is empty |
| add A to a group or channel | USER_PRIVACY_RESTRICTED |
| post in a group both are in | works 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.