Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create_service.rb « notes « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e969061f229d8a8ee6ce266cdf9a88a50c79af45 (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
module Notes
  class CreateService < BaseService
    def execute
      note = project.notes.new(params)
      note.author = current_user
      note.system = false

      if note.save
        notification_service.new_note(note)

        # Skip system notes, like status changes and cross-references.
        unless note.system
          event_service.leave_note(note, note.author)

          # Create a cross-reference note if this Note contains GFM that names an
          # issue, merge request, or commit.
          note.references.each do |mentioned|
            Note.create_cross_reference_note(mentioned, note.noteable, note.author, note.project)
          end

          execute_hooks(note)
        end
      end

      note
    end

    def hook_data(note)
      Gitlab::NoteDataBuilder.build(note, current_user)
    end

    def execute_hooks(note)
      note_data = hook_data(note)
      # TODO: Support Webhooks
      note.project.execute_services(note_data, :note_hooks)
    end
  end
end