Skip to content

Commit

Permalink
FIX: Handle missing letter avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
gschlager committed Apr 24, 2019
1 parent 3aa143a commit 03f9564
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/controllers/user_avatars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ def show_proxy_letter
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

Expand Down

1 comment on commit 03f9564

@ZogStriP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we extract the Time.new into a constant?

Please sign in to comment.