debian-mirror-gitlab/app/services/members/invite_member_builder.rb
2022-08-13 15:12:31 +05:30

19 lines
453 B
Ruby

# frozen_string_literal: true
module Members
class InviteMemberBuilder < StandardMemberBuilder
def execute
if user_by_email
find_or_initialize_member_by_user(user_by_email.id)
else
source.members_and_requesters.find_or_initialize_by(invite_email: invitee) # rubocop:disable CodeReuse/ActiveRecord
end
end
private
def user_by_email
source.users_by_emails([invitee])[invitee]
end
end
end