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

new_note.rb « builder « notification_recipients « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 27699a0d9cc23fb0cc03e7e5f48bda86564cd359 (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
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true

module NotificationRecipients
  module Builder
    class NewNote < Base
      attr_reader :note
      def initialize(note)
        @note = note
      end

      def target
        note.noteable
      end

      # NOTE: may be nil, in the case of a PersonalSnippet
      #
      # (this is okay because NotificationRecipient is written
      # to handle nil projects)
      def project
        note.project
      end

      def group
        if note.for_project_noteable?
          project.group
        else
          target.try(:group)
        end
      end

      def build!
        # Add all users participating in the thread (author, assignee, comment authors)
        add_participants(note.author)
        add_mentions(note.author, target: note)

        if note.for_project_noteable?
          # Merge project watchers
          add_project_watchers
        else
          add_group_watchers
        end

        add_custom_notifications
        add_subscribed_users
      end

      def custom_action
        :new_note
      end

      def acting_user
        note.author
      end
    end
  end
end