Class: IssueEmailParticipants::CreateService

Inherits:
BaseService show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/issue_email_participants/create_service.rb

Constant Summary collapse

MAX_NUMBER_OF_RECORDS =
10

Constants inherited from BaseService

BaseService::MAX_NUMBER_OF_EMAILS

Instance Attribute Summary

Attributes inherited from BaseService

#emails, #options, #target

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #group, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods inherited from BaseProjectService

#initialize

Methods inherited from BaseContainerService

#group_container?, #initialize, #namespace_container?, #project_container?, #project_group, #root_ancestor

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from IssueEmailParticipants::BaseService

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/issue_email_participants/create_service.rb', line 9

def execute
  return error_feature_flag unless Feature.enabled?(:issue_email_participants, target.project)
  return error_underprivileged unless user_privileged?
  return error_no_participants_added unless emails.present?

  added_emails = add_participants(deduplicate_and_limit_emails)

  if added_emails.any?
    message = add_system_note(added_emails)
    ServiceResponse.success(message: message.upcase_first << ".")
  else
    error_no_participants_added
  end
end