2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
# rubocop:disable GitlabSecurity/PublicSend
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
module API
|
|
|
|
module Helpers
|
|
|
|
module MembersHelpers
|
|
|
|
def find_source(source_type, id)
|
2018-03-17 18:26:18 +05:30
|
|
|
public_send("find_#{source_type}!", id) # rubocop:disable GitlabSecurity/PublicSend
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_admin_source!(source_type, source)
|
|
|
|
authorize! :"admin_#{source_type}", source
|
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
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-09-04 21:01:54 +05:30
|
|
|
MembersFinder.new(project, current_user).execute(include_invited_groups_members: true)
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def find_all_members_for_group(group)
|
2019-09-04 21:01:54 +05:30
|
|
|
GroupMembersFinder.new(group).execute
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|