Remove legacy avatar code
- Remove method that was only left around because the [api](https://github.com/discourse/discourse_api/pull/53) called it - Modify test to use new route instead of legacy route https://meta.discourse.org/t/legacy-route-for-avatars/22838/2
This commit is contained in:
parent
929ff00741
commit
e9e88c9b82
|
@ -430,34 +430,6 @@ class UsersController < ApplicationController
|
|||
render json: to_render
|
||||
end
|
||||
|
||||
# [LEGACY] avatars in quotes/oneboxes might still be pointing to this route
|
||||
# fixing it requires a rebake of all the posts
|
||||
def avatar
|
||||
user = User.find_by(username_lower: params[:username].downcase)
|
||||
if user.present?
|
||||
size = determine_avatar_size(params[:size])
|
||||
url = user.avatar_template.gsub("{size}", size.to_s)
|
||||
expires_in 1.day
|
||||
redirect_to url
|
||||
else
|
||||
raise ActiveRecord::RecordNotFound
|
||||
end
|
||||
end
|
||||
|
||||
def determine_avatar_size(size)
|
||||
size = size.to_i
|
||||
size = 64 if size == 0
|
||||
size = 10 if size < 10
|
||||
size = 128 if size > 128
|
||||
size
|
||||
end
|
||||
|
||||
# LEGACY: used by the API
|
||||
def upload_avatar
|
||||
params[:image_type] = "avatar"
|
||||
upload_user_image
|
||||
end
|
||||
|
||||
def upload_user_image
|
||||
params.require(:image_type)
|
||||
user = fetch_user_from_params
|
||||
|
|
|
@ -243,15 +243,12 @@ Discourse::Application.routes.draw do
|
|||
put "users/:username/preferences/badge_title" => "users#badge_title", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
get "users/:username/preferences/username" => "users#preferences", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
put "users/:username/preferences/username" => "users#username", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
get "users/:username/avatar(/:size)" => "users#avatar", constraints: {username: USERNAME_ROUTE_FORMAT} # LEGACY ROUTE
|
||||
post "users/:username/preferences/avatar" => "users#upload_avatar", constraints: {username: USERNAME_ROUTE_FORMAT} # LEGACY ROUTE
|
||||
post "users/:username/preferences/user_image" => "users#upload_user_image", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
delete "users/:username/preferences/user_image" => "users#destroy_user_image", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
put "users/:username/preferences/avatar/pick" => "users#pick_avatar", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
get "users/:username/preferences/card-badge" => "users#card_badge", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
put "users/:username/preferences/card-badge" => "users#update_card_badge", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
|
||||
|
||||
get "users/:username/invited" => "users#invited", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
post "users/action/send_activation_email" => "users#send_activation_email"
|
||||
get "users/:username/activity" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
|
|
|
@ -1218,7 +1218,7 @@ describe UsersController do
|
|||
upload = Fabricate(:upload)
|
||||
Upload.expects(:create_for).returns(upload)
|
||||
# enqueues the user_image generator job
|
||||
xhr :post, :upload_avatar, username: user.username, file: user_image_url, image_type: "avatar"
|
||||
xhr :post, :upload_user_image, username: user.username, file: user_image_url, image_type: "avatar"
|
||||
json = JSON.parse(response.body)
|
||||
json['url'].should == "/uploads/default/1/1234567890123456.png"
|
||||
json['width'].should == 100
|
||||
|
|
Loading…
Reference in New Issue