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

silent_mode_interceptor.rb « hook « email « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 774d4ac1f45f38eb63ee0c4c76d8eb51eafc59bd (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
# frozen_string_literal: true

module Gitlab
  module Email
    module Hook
      class SilentModeInterceptor
        def self.delivering_email(message)
          if ::Gitlab::SilentMode.enabled?
            message.perform_deliveries = false

            ::Gitlab::SilentMode.log_info(
              message: "SilentModeInterceptor prevented sending mail",
              mail_subject: message.subject
            )
          else
            ::Gitlab::SilentMode.log_debug(
              message: "SilentModeInterceptor did nothing",
              mail_subject: message.subject
            )
          end
        end
      end
    end
  end
end