mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Prevent critical emails bypassing disable, and improve email test logic
- The test_email job is removed, because it was always being run synchronously (not in sidekiq) -34b29f62added a bypass for critical emails, to match the spec. This removes the bypass, and removes the spec. - This adapts the specs for72ffabf6, so that they check for emails being sent - This reimplementsc2797921, allowing test emails to be sent even when emails are disabled
This commit is contained in:
committed by
Guo Xiang Tan
parent
48d0465f72
commit
a9d5ffbe3d
@@ -11,6 +11,7 @@ require 'uri'
|
||||
require 'net/smtp'
|
||||
|
||||
SMTP_CLIENT_ERRORS = [Net::SMTPFatalError, Net::SMTPSyntaxError]
|
||||
BYPASS_DISABLE_TYPES = ["admin_login", "test_message"]
|
||||
|
||||
module Email
|
||||
class Sender
|
||||
@@ -21,11 +22,10 @@ module Email
|
||||
@user = user
|
||||
end
|
||||
|
||||
def send(is_critical: false)
|
||||
if SiteSetting.disable_emails == "yes" &&
|
||||
@email_type.to_s != "admin_login" &&
|
||||
!is_critical
|
||||
def send
|
||||
bypass_disable = BYPASS_DISABLE_TYPES.include?(@email_type.to_s)
|
||||
|
||||
if SiteSetting.disable_emails == "yes" && !bypass_disable
|
||||
return
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ module Email
|
||||
return skip(SkippedEmailLog.reason_types[:sender_message_blank]) if @message.blank?
|
||||
return skip(SkippedEmailLog.reason_types[:sender_message_to_blank]) if @message.to.blank?
|
||||
|
||||
if SiteSetting.disable_emails == "non-staff"
|
||||
if SiteSetting.disable_emails == "non-staff" && !bypass_disable
|
||||
return unless User.find_by_email(to_address)&.staff?
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user