debian-mirror-gitlab/app/serializers/user_serializer.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
681 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
class UserSerializer < BaseSerializer
entity UserEntity
2019-10-12 21:52:04 +05:30
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))
2022-11-25 23:54:43 +05:30
super(resource, opts.merge(merge_request: merge_request, suggested: params[:suggested]), MergeRequestUserEntity)
2019-10-12 21:52:04 +05:30
else
super
end
end
private
def preload_max_member_access(project, users)
project.team.max_member_access_for_user_ids(users.map(&:id))
end
2018-03-17 18:26:18 +05:30
end
2021-02-22 17:27:13 +05:30
2021-06-08 01:23:25 +05:30
UserSerializer.prepend_mod_with('UserSerializer')