FIX: Handle missing letter avatar

FIX: Handle missing letter avatar

diff --git a/app/controllers/user_avatars_controller.rb b/app/controllers/user_avatars_controller.rb
index 0fa0d32..8a61bfa 100644
--- a/app/controllers/user_avatars_controller.rb
+++ b/app/controllers/user_avatars_controller.rb
@@ -43,8 +43,13 @@ class UserAvatarsController < ApplicationController
     params.require(:color)
     params.require(:version)
     params.require(:size)
+
     hijack do
-      proxy_avatar("https://avatars.discourse.org/#{params[:version]}/letter/#{params[:letter]}/#{params[:color]}/#{params[:size]}.png", Time.new('1990-01-01'))
+      begin
+        proxy_avatar("https://avatars.discourse.org/#{params[:version]}/letter/#{params[:letter]}/#{params[:color]}/#{params[:size]}.png", Time.new('1990-01-01'))
+      rescue OpenURI::HTTPError
+        render_blank
+      end
     end
   end

GitHub sha: 03f95648

1 Like

Should we extract the Time.new into a constant?

1 Like