Skip to content

fix(profile): set_privacy_settings merges exceptions instead of opening privacy to everyone - #325

Merged
chigwell merged 1 commit into
chigwell:mainfrom
axisrow:ao/pr-axisrow-telegram-3/up-privacy-exceptions
Oct 17, 2026
Merged

chigwell merged 1 commit into
chigwell:mainfrom
axisrow:ao/pr-axisrow-telegram-3/up-privacy-exceptions

Conversation

@axisrow

@axisrow axisrow commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Before

set_privacy_settings never read the current rules: it built a fresh list and passed it to account.setPrivacy, which replaces the rules for the key. With allow_users empty it sent InputPrivacyValueAllowAll(), so a request like

set_privacy_settings(key="phone", disallow_users=["@spammer"])

turned an account whose phone visibility was Nobody into Everybody, and dropped every existing exception (user allow/disallow lists, contacts-only, close friends). Unresolvable users were silently skipped, and the tool still answered "Privacy settings for phone updated successfully."

After

  • Reads the current rules with account.getPrivacy, keeps the main choice and all existing exceptions, and merges the requested users into the per-user allow/disallow lists (a user named in one list leaves the other; exceptions first, main choice last — the order the official apps send).
  • Sends nothing unless every requested user resolves: Error: Could not find a requested user; privacy settings were not changed.
  • Refuses the account itself as an exception, refuses to drop a rule type this build cannot re-encode (schema drift), and refuses an empty call instead of opening the setting to everyone.
  • The key mapping / helper cleanup also drops the per-call re-imports and the unreachable TypeError compatibility branch.

Tests

tests/test_privacy_settings.py pins the before/after cases: disallow-one under Nobody and under Everybody (main choice kept, exception first), existing exceptions kept and a user moved between lists, no change on unknown user, self, unsupported rule, and the empty call. Suite: 1243 passed (one run).

Closes #324. Mirrors axisrow#13, already merged in my fork.

🤖 Generated with Claude Code

…ng privacy to everyone

Mirrors #13. The old implementation rebuilt the rules
list from scratch: with allow_users empty it sent InputPrivacyValueAllowAll,
silently replacing the account's main privacy choice (e.g. phone "nobody"
became "everybody") and dropping every existing exception. Now the tool
reads the current rules via account.getPrivacy, keeps the main choice and
all exceptions, adds/updates the per-user allow/disallow exceptions, and
refuses to touch anything when a user cannot be resolved, when the account
itself is named, or when the server returns a rule this build cannot
re-encode.

Co-Authored-By: Claude Code <[email protected]>
@chigwell
chigwell merged commit 20eaff3 into chigwell:main Oct 17, 2026
4 checks passed
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.

set_privacy_settings silently replaces all privacy rules and can open phone/last seen/profile photo to everyone

2 participants