mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08: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) - 34b29f62 added a bypass for critical emails, to match the spec. This removes the bypass, and removes the spec. - This adapts the specs for 72ffabf6, so that they check for emails being sent - This reimplements c2797921, 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
@ -10,14 +10,10 @@ class Admin::EmailController < Admin::AdminController
|
||||
def test
|
||||
params.require(:email_address)
|
||||
begin
|
||||
Jobs::TestEmail.new.execute(to_address: params[:email_address])
|
||||
if SiteSetting.disable_emails == "yes"
|
||||
render json: { sent_test_email_message: I18n.t("admin.email.sent_test_disabled") }
|
||||
elsif SiteSetting.disable_emails == "non-staff" && !User.find_by_email(params[:email_address])&.staff?
|
||||
render json: { sent_test_email_message: I18n.t("admin.email.sent_test_disabled_for_non_staff") }
|
||||
else
|
||||
render json: { sent_test_email_message: I18n.t("admin.email.sent_test") }
|
||||
end
|
||||
message = TestMailer.send_test(params[:email_address])
|
||||
Email::Sender.new(message, :test_message).send
|
||||
|
||||
render json: { sent_test_email_message: I18n.t("admin.email.sent_test") }
|
||||
rescue => e
|
||||
render json: { errors: [e.message] }, status: 422
|
||||
end
|
||||
|
Reference in New Issue
Block a user