2018-07-19 14:43:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-23 18:10:05 -04:00
|
|
|
class UserSerializer < BaseSerializer
|
|
|
|
entity UserEntity
|
2019-08-01 12:51:14 -04:00
|
|
|
|
|
|
|
def represent(resource, opts = {}, entity = nil)
|
|
|
|
if params[:merge_request_iid]
|
|
|
|
merge_request = opts[:project].merge_requests.find_by_iid!(params[:merge_request_iid])
|
|
|
|
preload_max_member_access(merge_request.project, Array(resource))
|
|
|
|
|
2020-12-03 22:09:49 -05:00
|
|
|
super(resource, opts.merge(merge_request: merge_request), MergeRequestUserEntity)
|
2019-08-01 12:51:14 -04:00
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def preload_max_member_access(project, users)
|
|
|
|
project.team.max_member_access_for_user_ids(users.map(&:id))
|
|
|
|
end
|
2017-06-23 18:10:05 -04:00
|
|
|
end
|
2020-12-03 22:09:49 -05:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
UserSerializer.prepend_mod_with('UserSerializer')
|