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.

38 lines
982 B
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)
2023-03-04 22:38:38 +05:30
track_timeline_event('incident_management_timeline_event_deleted', project)
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)
SystemNoteService.delete_timeline_event(incident, user)
end
end
end
end