diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-03 09:11:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-03 09:11:13 +0300 |
commit | ccbe90951fb75b3527eaaad404e6abb6ed09ca8c (patch) | |
tree | 610bb73131ffde9b436635e4ac47f8dded9b91ba /app/helpers | |
parent | 8d9c82762d6c4f10f4d3eba5d484179f98c284b0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/avatars_helper.rb | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index 5457f96d506..8d22bda279f 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -22,11 +22,14 @@ module AvatarsHelper end def avatar_icon_for_email(email = nil, size = nil, scale = 2, only_path: true) - user = User.find_by_any_email(email) - if user - avatar_icon_for_user(user, size, scale, only_path: only_path) + return gravatar_icon(email, size, scale) if email.nil? + + if Feature.enabled?(:avatar_cache_for_email, @current_user, type: :development) + Gitlab::AvatarCache.by_email(email, size, scale, only_path) do + avatar_icon_by_user_email_or_gravatar(email, size, scale, only_path: only_path) + end else - gravatar_icon(email, size, scale) + avatar_icon_by_user_email_or_gravatar(email, size, scale, only_path: only_path) end end @@ -101,19 +104,23 @@ module AvatarsHelper private - def user_avatar_url_for(only_path: true, **options) - return options[:url] if options[:url] - - email = options[:user_email] - user = options.key?(:user) ? options[:user] : User.find_by_any_email(email) + def avatar_icon_by_user_email_or_gravatar(email, size, scale, only_path:) + user = User.find_by_any_email(email) if user - avatar_icon_for_user(user, options[:size], only_path: only_path) + avatar_icon_for_user(user, size, scale, only_path: only_path) else - gravatar_icon(email, options[:size]) + gravatar_icon(email, size, scale) end end + def user_avatar_url_for(only_path: true, **options) + return options[:url] if options[:url] + return avatar_icon_for_user(options[:user], options[:size], only_path: only_path) if options[:user] + + avatar_icon_for_email(options[:user_email], options[:size], only_path: only_path) + end + def source_icon(source, options = {}) avatar_url = source.try(:avatar_url) |