Skip to content

Commit

Permalink
fix: do not attach avatar case it fails to download
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadrien Froger committed Feb 11, 2025
1 parent 122cae8 commit 1e9d080
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ def create_or_find_user
@user.newsletter_notifications_at = nil
@user.password = SecureRandom.hex
if form.avatar_url.present?
url = URI.parse(form.avatar_url)
filename = File.basename(url.path)
file = url.open
@user.avatar.attach(io: file, filename:)
begin
url = URI.parse(form.avatar_url)
filename = File.basename(url.path)
file = url.open
@user.avatar.attach(io: file, filename:)
rescue OpenURI::HTTPError, Errno::ECONNREFUSED => e
# Do not attach the avatar, as it fails to fetch it.
end
end
@user.tos_agreement = form.tos_agreement
@user.accepted_tos_version = Time.current
Expand Down

0 comments on commit 1e9d080

Please sign in to comment.