debian-mirror-gitlab/lib/gitlab/email/hook/silent_mode_interceptor.rb
2023-06-20 00:43:36 +05:30

27 lines
739 B
Ruby

# frozen_string_literal: true
module Gitlab
module Email
module Hook
class SilentModeInterceptor
def self.delivering_email(message)
if Gitlab::CurrentSettings.silent_mode_enabled?
message.perform_deliveries = false
Gitlab::AppJsonLogger.info(
message: "SilentModeInterceptor prevented sending mail",
mail_subject: message.subject,
silent_mode_enabled: true
)
else
Gitlab::AppJsonLogger.debug(
message: "SilentModeInterceptor did nothing",
mail_subject: message.subject,
silent_mode_enabled: false
)
end
end
end
end
end
end