mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Merge pull request #3026 from oblakeerickson/legacy_avatar
Remove legacy avatar code
This commit is contained in:
commit
fdecd69228
3 changed files with 1 additions and 32 deletions
|
@ -430,34 +430,6 @@ class UsersController < ApplicationController
|
||||||
render json: to_render
|
render json: to_render
|
||||||
end
|
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
|
def upload_user_image
|
||||||
params.require(:image_type)
|
params.require(:image_type)
|
||||||
user = fetch_user_from_params
|
user = fetch_user_from_params
|
||||||
|
|
|
@ -244,15 +244,12 @@ Discourse::Application.routes.draw do
|
||||||
put "users/:username/preferences/badge_title" => "users#badge_title", constraints: {username: USERNAME_ROUTE_FORMAT}
|
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}
|
get "users/:username/preferences/username" => "users#preferences", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||||
put "users/:username/preferences/username" => "users#username", 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}
|
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}
|
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}
|
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}
|
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}
|
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}
|
get "users/:username/invited" => "users#invited", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||||
post "users/action/send_activation_email" => "users#send_activation_email"
|
post "users/action/send_activation_email" => "users#send_activation_email"
|
||||||
get "users/:username/activity" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}
|
get "users/:username/activity" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||||
|
|
|
@ -1218,7 +1218,7 @@ describe UsersController do
|
||||||
upload = Fabricate(:upload)
|
upload = Fabricate(:upload)
|
||||||
Upload.expects(:create_for).returns(upload)
|
Upload.expects(:create_for).returns(upload)
|
||||||
# enqueues the user_image generator job
|
# 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 = JSON.parse(response.body)
|
||||||
json['url'].should == "/uploads/default/1/1234567890123456.png"
|
json['url'].should == "/uploads/default/1/1234567890123456.png"
|
||||||
json['width'].should == 100
|
json['width'].should == 100
|
||||||
|
|
Loading…
Reference in a new issue