2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
module API
|
2021-01-03 14:25:43 +05:30
|
|
|
class Avatar < ::API::Base
|
2023-04-23 21:23:45 +05:30
|
|
|
feature_category :user_profile
|
2022-07-23 23:45:48 +05:30
|
|
|
urgency :medium
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
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
|