Class: Issues::CloseService
- Inherits:
-
BaseService
- Object
- BaseContainerService
- IssuableBaseService
- BaseService
- Issues::CloseService
- Defined in:
- app/services/issues/close_service.rb
Constant Summary
Constants inherited from BaseService
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
-
#close_issue(issue, closed_via: nil, notifications: true, system_note: true) ⇒ Object
Closes the supplied issue without checking if the user is authorized to do so.
-
#execute(issue, commit: nil, notifications: true, system_note: true, skip_authorization: false) ⇒ Object
Closes the supplied issue if the current user is able to do so.
Methods inherited from BaseService
#close_service, #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
Methods included from IncidentManagement::UsageData
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, #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
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
Instance Method Details
#close_issue(issue, closed_via: nil, notifications: true, system_note: true) ⇒ 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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/services/issues/close_service.rb', line 22 def close_issue(issue, closed_via: nil, notifications: true, system_note: true) if issue.is_a?(ExternalIssue) close_external_issue(issue, closed_via) return issue end if issue.close(current_user) event_service.close_issue(issue, current_user) create_note(issue, closed_via) if system_note if current_user.project_bot? log_audit_event(issue, current_user, "#{issue.issue_type}_closed_by_project_bot", "Closed #{issue.issue_type.humanize(capitalize: false)} #{issue.title}") end closed_via = _("commit %{commit_id}") % { commit_id: closed_via.id } if closed_via.is_a?(Commit) notification_service.async.close_issue(issue, current_user, { closed_via: closed_via }) if notifications todo_service.close_issue(issue, current_user) perform_incident_management_actions(issue) execute_hooks(issue, 'close') invalidate_cache_counts(issue, users: issue.assignees) issue.update_project_counter_caches track_incident_action(current_user, issue, :incident_closed) if closed_via.is_a?(MergeRequest) store_first_mentioned_in_commit_at(issue, closed_via) Onboarding::ProgressService.new(project.namespace).execute(action: :issue_auto_closed) end Milestones::ClosedIssuesCountService.new(issue.milestone).delete_cache if issue.milestone end issue end |
#execute(issue, commit: nil, notifications: true, system_note: true, skip_authorization: false) ⇒ Object
Closes the supplied issue if the current user is able to do so.
6 7 8 9 10 11 12 13 14 15 |
# File 'app/services/issues/close_service.rb', line 6 def execute(issue, commit: nil, notifications: true, system_note: true, skip_authorization: false) return issue unless can_close?(issue, skip_authorization: ) close_issue( issue, closed_via: commit, notifications: notifications, system_note: system_note ) end |