debian-mirror-gitlab/app/services/incident_management/timeline_events/destroy_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1 KiB
Ruby
Raw Normal View History

2022-07-16 23:28:13 +05:30
# frozen_string_literal: true
module IncidentManagement
module TimelineEvents
class DestroyService < TimelineEvents::BaseService
# @param timeline_event [IncidentManagement::TimelineEvent]
# @param user [User]
def initialize(timeline_event, user)
@timeline_event = timeline_event
@user = user
@incident = timeline_event.incident
@project = @incident.project
end
def execute
return error_no_permissions unless allowed?
if timeline_event.destroy
add_system_note(incident, user)
2022-07-23 23:45:48 +05:30
track_usage_event(:incident_management_timeline_event_deleted, user.id)
2022-07-16 23:28:13 +05:30
success(timeline_event)
else
error_in_save(timeline_event)
end
end
private
attr_reader :project, :timeline_event, :user, :incident
def add_system_note(incident, user)
return unless Feature.enabled?(:incident_timeline, project)
SystemNoteService.delete_timeline_event(incident, user)
end
end
end
end