summaryrefslogtreecommitdiff
path: root/app/services/notes/update_service.rb
blob: b5611d46257b63d835a6b13791beccd46e25ca61 (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
module Notes
  class UpdateService < BaseService
    def execute
      note = project.notes.find(params[:note_id])
      note.note = params[:note]
      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|
            SystemNoteService.cross_reference(mentioned, note.noteable, note.author)
          end
        end
      end

      note
    end
  end
end