minor, bypass gravatar update if user does not match

this protects against a race condition that can happen when a user record
is destroyed reasonably quickly
This commit is contained in:
Sam 2018-10-23 12:20:21 +11:00
parent cee51672c9
commit de6b585368
1 changed files with 1 additions and 1 deletions

View File

@ -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
if user && avatar && avatar.user&.id == user.id
avatar.update_gravatar!
if !user.uploaded_avatar_id && avatar.gravatar_upload_id
user.update_column(:uploaded_avatar_id, avatar.gravatar_upload_id)