diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6928cc579..64b7fc8ac 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 271d7d636..4c716ed72 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -244,15 +244,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} diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index d5f203e61..f682ab631 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -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