blob: 61802ba09ce0a56604d202973bf6b64f22aad680 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
module Members
class CreateService < Members::BaseService
DEFAULT_LIMIT = 100
def execute
return error('No users specified.') if params[:user_ids].blank?
user_ids = params[:user_ids].split(',').uniq
return error("Too many users specified (limit is #{user_limit})") if
user_limit && user_ids.size > user_limit
members = source.add_users(
user_ids,
params[:access_level],
expires_at: params[:expires_at],
current_user: current_user
)
members.compact.each { |member| after_execute(member: member) }
success
end
private
def user_limit
limit = params.fetch(:limit, DEFAULT_LIMIT)
limit && limit < 0 ? nil : limit
end
end
end
|