FIX: redirect old avatars to proper user_avatar route

This commit is contained in:
Régis Hanol 2014-08-18 17:45:07 +02:00
parent 60b46f837b
commit 5b3a758ba9

View file

@ -52,14 +52,13 @@ class UserAvatarsController < ApplicationController
image = nil
version = params[:version].to_i
return render_dot unless version > 0 && user_avatar = user.user_avatar
upload = Upload.find_by(id: version) if user_avatar.contains_upload?(version)
upload ||= user.uploaded_avatar if user.uploaded_avatar_id == version
if user.uploaded_avatar && !upload
return redirect_to "/avatar/#{hostname}/#{user.username_lower}/#{size}/#{user.uploaded_avatar_id}.png"
return redirect_to "/user_avatar/#{hostname}/#{user.username_lower}/#{size}/#{user.uploaded_avatar_id}.png"
elsif upload
original = Discourse.store.path_for(upload)
if Discourse.store.external? || File.exists?(original)