Class: Issues::CloseService

Inherits:
BaseService show all
Includes:
Gitlab::Loggable
Defined in:
app/services/issues/close_service.rb

Constant Summary

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants inherited from BaseService

BaseService::EpicAssignmentError, BaseService::NO_REBALANCING_NEEDED

Constants included from Gitlab::Utils::UsageData

Gitlab::Utils::UsageData::DISTRIBUTED_HLL_FALLBACK, Gitlab::Utils::UsageData::FALLBACK, Gitlab::Utils::UsageData::HISTOGRAM_FALLBACK, Gitlab::Utils::UsageData::MAX_BUCKET_SIZE

Instance Attribute Summary

Attributes inherited from BaseContainerService

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

Instance Method Summary collapse

Methods included from Gitlab::Loggable

#build_structured_payload

Methods inherited from BaseService

#available_callbacks, #close_service, #execute_hooks, #hook_data, #rebalance_if_needed, #reopen_service

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from IssueTypeHelpers

#create_issue_type_allowed?

Methods included from IncidentManagement::UsageData

#track_incident_action

Methods included from Gitlab::Utils::UsageData

#add, #add_metric, #alt_usage_data, #average, #count, #distinct_count, #estimate_batch_distinct_count, #histogram, #maximum_id, #measure_duration, #metrics_collection_metadata, #minimum_id, #redis_usage_data, #sum, #track_usage_event, #with_finished_at, #with_metadata, #with_prometheus_client

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?

Instance Method Details

#close_issue(issue, closed_via: nil, notifications: true, system_note: true, status: nil) ⇒ Object

Closes the supplied issue without checking if the user is authorized to do so.

The code calling this method is responsible for ensuring that a user is allowed to close the given issue.



22
23
24
25
26
27
28
29
30
31
32
# File 'app/services/issues/close_service.rb', line 22

def close_issue(issue, closed_via: nil, notifications: true, system_note: true, status: nil)
  if issue.is_a?(ExternalIssue)
    close_external_issue(issue, closed_via)

    return issue
  end

  return issue unless handle_closing_issue!(issue, current_user)

  after_close(issue, status, closed_via: closed_via, notifications: notifications, system_note: system_note)
end

#execute(issue, commit: nil, notifications: true, system_note: true, skip_authorization: false, status: nil) ⇒ Object

Closes the supplied issue if the current user is able to do so.



8
9
10
11
12
13
14
15
# File 'app/services/issues/close_service.rb', line 8

def execute(issue, commit: nil, notifications: true, system_note: true, skip_authorization: false, status: nil)
  unless can_close?(issue, skip_authorization: skip_authorization)
    log_failed_auth(issue, commit)
    return issue
  end

  close_issue(issue, closed_via: commit, notifications: notifications, system_note: system_note, status: status)
end