diff options
author | Imre <ifarkas@gitlab.com> | 2018-05-18 10:49:02 +0200 |
---|---|---|
committer | Imre Farkas <ifarkas@gitlab.com> | 2018-06-06 10:12:52 +0200 |
commit | c8f0e4b5da0c9d578035e74b524f5adcb80efcf6 (patch) | |
tree | 4e0a2624c77f42bebf1d06098074c61115828b2f /lib/api/avatar.rb | |
parent | fe0ebf76c49e2512b211c5d43152275c536f7e3a (diff) | |
download | gitlab-ce-c8f0e4b5da0c9d578035e74b524f5adcb80efcf6.tar.gz |
Add Avatar API
Diffstat (limited to 'lib/api/avatar.rb')
-rw-r--r-- | lib/api/avatar.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/api/avatar.rb b/lib/api/avatar.rb new file mode 100644 index 00000000000..70219bc8ea0 --- /dev/null +++ b/lib/api/avatar.rb @@ -0,0 +1,21 @@ +module API + class Avatar < Grape::API + 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 |