2020-01-26 13:08:47 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class User < UserBasic
|
2020-04-21 11:21:10 -04:00
|
|
|
include UsersHelper
|
2020-01-26 13:08:47 -05:00
|
|
|
expose :created_at, if: ->(user, opts) { Ability.allowed?(opts[:current_user], :read_user_profile, user) }
|
2020-07-09 20:09:13 -04:00
|
|
|
expose :bio, :bio_html, :location, :public_email, :skype, :linkedin, :twitter, :website_url, :organization, :job_title
|
2021-02-01 07:09:03 -05:00
|
|
|
expose :bot?, as: :bot
|
2020-04-21 11:21:10 -04:00
|
|
|
expose :work_information do |user|
|
|
|
|
work_information(user)
|
|
|
|
end
|
2021-02-15 16:08:59 -05:00
|
|
|
expose :followers, if: ->(user, opts) { Ability.allowed?(opts[:current_user], :read_user_profile, user) } do |user|
|
2021-03-29 08:09:14 -04:00
|
|
|
user.followers.size
|
2021-02-15 16:08:59 -05:00
|
|
|
end
|
|
|
|
expose :following, if: ->(user, opts) { Ability.allowed?(opts[:current_user], :read_user_profile, user) } do |user|
|
2021-03-29 08:09:14 -04:00
|
|
|
user.followees.size
|
2021-02-15 16:08:59 -05:00
|
|
|
end
|
2020-01-26 13:08:47 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|