2018-09-29 18:34:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-18 04:49:02 -04:00
|
|
|
module API
|
2020-10-14 20:08:42 -04:00
|
|
|
class Avatar < ::API::Base
|
2020-10-28 11:08:49 -04:00
|
|
|
feature_category :users
|
2022-05-20 17:08:53 -04:00
|
|
|
urgency :medium
|
2020-10-28 11:08:49 -04:00
|
|
|
|
2018-05-18 04:49:02 -04:00
|
|
|
resource :avatar do
|
|
|
|
desc 'Return avatar url for a user' do
|
|
|
|
success Entities::Avatar
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :email, type: String, desc: 'Public email address of the user'
|
|
|
|
optional :size, type: Integer, desc: 'Single pixel dimension for Gravatar images'
|
|
|
|
end
|
|
|
|
get do
|
|
|
|
forbidden!('Unauthorized access') unless can?(current_user, :read_users_list)
|
|
|
|
|
|
|
|
user = User.find_by_public_email(params[:email])
|
|
|
|
user ||= User.new(email: params[:email])
|
|
|
|
|
|
|
|
present user, with: Entities::Avatar, size: params[:size]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|