Class: JiraConnectSubscriptions::CreateService

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

Constant Summary collapse

MERGE_REQUEST_SYNC_BATCH_SIZE =
20
MERGE_REQUEST_SYNC_BATCH_DELAY =
1.minute.freeze

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #jira_connect_installation, #params

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods inherited from BaseService

#initialize

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?

Constructor Details

This class inherits a constructor from JiraConnectSubscriptions::BaseService

Instance Method Details

#executeObject



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

def execute
  if !params[:jira_user]
    return error(s_('JiraConnect|Could not fetch user information from Jira. ' \
                    'Check the permissions in Jira and try again.'), 403)
  elsif !can_administer_jira?
    return error(s_('JiraConnect|The Jira user is not a site administrator. ' \
                    'Check the permissions in Jira and try again.'), 403)
  end

  unless namespace && can?(current_user, :create_jira_connect_subscription, namespace)
    return error(s_('JiraConnect|Cannot find namespace. Make sure you have sufficient permissions.'), 401)
  end

  create_subscription
end