debian-mirror-gitlab/lib/api/entities/user.rb

22 lines
811 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module API
module Entities
class User < UserBasic
2020-04-22 19:07:51 +05:30
include UsersHelper
2020-03-13 15:44:24 +05:30
expose :created_at, if: ->(user, opts) { Ability.allowed?(opts[:current_user], :read_user_profile, user) }
2021-09-30 23:02:18 +05:30
expose :bio, :bio_html, :location, :public_email, :skype, :linkedin, :twitter, :website_url, :organization, :job_title, :pronouns
2021-03-11 19:13:27 +05:30
expose :bot?, as: :bot
2020-04-22 19:07:51 +05:30
expose :work_information do |user|
work_information(user)
end
2021-03-11 19:13:27 +05:30
expose :followers, if: ->(user, opts) { Ability.allowed?(opts[:current_user], :read_user_profile, user) } do |user|
2021-04-29 21:17:54 +05:30
user.followers.size
2021-03-11 19:13:27 +05:30
end
expose :following, if: ->(user, opts) { Ability.allowed?(opts[:current_user], :read_user_profile, user) } do |user|
2021-04-29 21:17:54 +05:30
user.followees.size
2021-03-11 19:13:27 +05:30
end
2020-03-13 15:44:24 +05:30
end
end
end