8000 8000
Skip to content

Conversation

@prakhar1144
Copy link
Member
@prakhar1144 prakhar1144 commented Dec 23, 2025

This PR includes improvements in the avatar codepath I noticed, while working on Jdenticon PR.

See commit messages for details.

Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

Signed-off-by: Prakhar Pratyush <prakhar@zulip.com>
Making a call to `DELETE users/me/avatar` when avatar_source is
already gravatar resulted in increasing avatar_version,
creating realmauditlog, and sending an event to clients.

This commit makes changes to avoid doing so.

Signed-off-by: Prakhar Pratyush <prakhar@zulip.com>
Signed-off-by: Prakhar Pratyush <prakhar@zulip.com>
In `build_avatar_url`, a possible combination for integration bot was:
* avatar_url = slack image url
* avatar_source = UserProfile.AVATAR_FROM_GRAVATAR

Currently, avatar_url returned by this function is not used if
avatar_source is gravatar. So, this doesn't cause a bug.

But it is incorrect logically, and can cause bug in future.

This commit makes improvement to set avatar_url = None when
avatar_source is gravatar. The url is set only if avatar_source
is UserProfile.AVATAR_FROM_USER.

Signed-off-by: Prakhar Pratyush <prakhar@zulip.com>
`do_delete_avatar_image` was only used in `do_scrub_realm`, it's not
intended to be used in delete_avatar_backend (`POST /users/me/avatar`).

The difference between the two is just changing the avatar_source
vs changing avatar_source as well as deleting the image from storage.

This commit renames `do_delete_avatar_image` to `do_scrub_avatar_image`
for clarity.

Signed-off-by: Prakhar Pratyush <prakhar@zulip.com>
While scrubbing a realm, there's no need to attempt sending an event
to clients for avatar fields change.

In `do_scrub_avatar_image` we were doing so.

Signed-off-by: Prakhar Pratyush <prakhar@zulip.com>
@prakhar1144 prakhar1144 marked this pull request as ready for review December 23, 2025 09:48
@prakhar1144 prakhar1144 added the integration review Added by maintainers when a PR may be ready for integration. label Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration review Added by maintainers when a PR may be ready for integration. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0