blob: 73a20b8a380f3a4d63b3aa8e99e4e6c437b2c0d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
|
# frozen_string_literal: true
module Mutations
module IncidentManagement
module TimelineEvent
class PromoteFromNote < Base
graphql_name 'TimelineEventPromoteFromNote'
argument :note_id, Types::GlobalIDType[::Note],
required: true,
description: 'Note ID from which the timeline event promoted.'
def resolve(note_id:)
note = find_object(id: note_id)
incident = note&.noteable
authorize!(incident)
response ::IncidentManagement::TimelineEvents::CreateService.new(
incident,
current_user,
promoted_from_note: note,
note: note.note,
occurred_at: note.created_at
).execute
end
private
def find_object(id:)
GitlabSchema.object_from_id(id, expected_type: ::Note).sync
end
def authorize!(object)
raise_noteable_not_incident! if object && !object.try(:incident?)
super
end
def raise_noteable_not_incident!
raise_resource_not_available_error! 'Note does not belong to an incident'
end
end
end
end
end
|