2018-09-29 18:34:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-03 22:20:34 -04:00
|
|
|
# rubocop:disable GitlabSecurity/PublicSend
|
|
|
|
|
2016-06-23 11:14:31 -04:00
|
|
|
module API
|
|
|
|
module Helpers
|
|
|
|
module MembersHelpers
|
|
|
|
def find_source(source_type, id)
|
2017-08-03 22:20:34 -04:00
|
|
|
public_send("find_#{source_type}!", id) # rubocop:disable GitlabSecurity/PublicSend
|
2016-06-23 11:14:31 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_admin_source!(source_type, source)
|
|
|
|
authorize! :"admin_#{source_type}", source
|
|
|
|
end
|
2018-07-25 17:45:42 -04:00
|
|
|
|
|
|
|
def find_all_members(source_type, source)
|
|
|
|
members = source_type == 'project' ? find_all_members_for_project(source) : find_all_members_for_group(source)
|
|
|
|
members.non_invite
|
|
|
|
.non_request
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_all_members_for_project(project)
|
2019-01-29 13:10:37 -05:00
|
|
|
MembersFinder.new(project, current_user).execute(include_invited_groups_members: true)
|
2018-07-25 17:45:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def find_all_members_for_group(group)
|
2019-01-29 13:10:37 -05:00
|
|
|
GroupMembersFinder.new(group).execute
|
2018-07-25 17:45:42 -04:00
|
|
|
end
|
2016-06-23 11:14:31 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|