New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable12] Fix own avatar not updated when display name is changed #8130

Merged
merged 1 commit into from Feb 27, 2018

Conversation

Projects
None yet
3 participants
@danxuliu
Member

danxuliu commented Jan 31, 2018

The avatar endpoint returns the avatar image or, if the user has no avatar, the display name. In that later case the avatar is generated on the browser based on the display name. The avatar endpoint response is cached, so when the display name changes and the avatar is got again the browser could use the cached value, in which case it would use the same display name as before and the avatar would not change.

When the avatar is an image the cache is invalidated with the use of the version parameter, which is increased when the image changes. When the avatar cache was first introduced only the image avatars were cached, but it was later changed to cache all avatar responses to limit the requests made to the server. Thus, now the cache of the display name is invalidated too by increasing the version of the avatar if the display name changes and there is no explicit avatar set.

In Nextcloud 13 and current master the avatar is always generated by the server, so these changes should not be needed in those versions.

How to test this:

  • Open the personal settings (with a browser that respects the cache time suggested by the server)
    • If there is an avatar image, remove it and refresh the page
  • The avatar is the first letter of the display name of the user. Change the display name so it starts with a different letter and refresh the page; with this pull request the avatar is updated, without it the old letter is still shown.
Fix own avatar not updated when display name is changed
The avatar endpoint returns the avatar image or, if the user has no
avatar, the display name. In that later case the avatar is generated on
the browser based on the display name. The avatar endpoint response is
cached, so when the display name changes and the avatar is got again the
browser could use the cached value, in which case it would use the same
display name as before and the avatar would not change.

When the avatar is an image the cache is invalidated with the use of
the "version" parameter, which is increased when the image changes. When
the avatar cache was first introduced only the image avatars were
cached, but it was later changed to cache all avatar responses to limit
the requests made to the server. Thus, now the cache of the display name
is invalidated too by increasing the version of the avatar if the
display name changes and there is no explicit avatar set.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
@codecov

This comment has been minimized.

codecov bot commented Jan 31, 2018

Codecov Report

Merging #8130 into stable12 will increase coverage by <.01%.
The diff coverage is 100%.

@@              Coverage Diff               @@
##             stable12    #8130      +/-   ##
==============================================
+ Coverage       53.84%   53.85%   +<.01%     
- Complexity      22761    22766       +5     
==============================================
  Files            1385     1385              
  Lines           87150    87159       +9     
  Branches         1331     1331              
==============================================
+ Hits            46926    46936      +10     
+ Misses          40224    40223       -1
Impacted Files Coverage Δ Complexity Δ
lib/private/AvatarManager.php 73.33% <100%> (+11.42%) 9 <4> (+5) ⬆️
lib/private/Files/Cache/Propagator.php 96.2% <0%> (+1.26%) 16% <0%> (ø) ⬇️
@rullzer

rullzer approved these changes Feb 1, 2018

@rullzer rullzer requested a review from icewind1991 Feb 8, 2018

@MorrisJobke

Tested and works

@MorrisJobke MorrisJobke merged commit 6f4b6be into stable12 Feb 27, 2018

3 checks passed

codecov/patch 100% of diff hit (target 53.84%)
Details
codecov/project 53.85% (+<.01%) compared to 0809f2a
Details
continuous-integration/drone/pr the build was successful
Details

@MorrisJobke MorrisJobke deleted the fix-own-avatar-not-updated-when-display-name-is-changed branch Feb 27, 2018

@MorrisJobke MorrisJobke referenced this pull request Mar 9, 2018

Merged

12.0.6 RC 1 #8750

2 of 2 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment