FIX: don't update gravatar if the user has no email

FIX: don’t update gravatar if the user has no email

diff --git a/app/jobs/regular/update_gravatar.rb b/app/jobs/regular/update_gravatar.rb
index 53d4f61..e993c0b 100644
--- a/app/jobs/regular/update_gravatar.rb
+++ b/app/jobs/regular/update_gravatar.rb
@@ -8,7 +8,7 @@ module Jobs
       user = User.find_by(id: args[:user_id])
       avatar = UserAvatar.find_by(id: args[:avatar_id])
 
-      if user && avatar && avatar.user&.id == user.id
+      if user && avatar && avatar.user&.id == user.id && user.email.present?
         avatar.update_gravatar!
         if !user.uploaded_avatar_id && avatar.gravatar_upload_id
           user.update_column(:uploaded_avatar_id, avatar.gravatar_upload_id)

GitHub sha: e3a23116

Do we need a test for this?

How would we end up with a user without an email address? I think we make this same assumption in many parts of the application?

1 Like

Its so rare, I am not sure we need to carry a test here for this huge level of strange.

1 Like