UX: Improve email testing admin tool. (#6308)

This commit is contained in:
Bianca Nenciu
2018-08-29 23:14:16 +02:00
committed by Régis Hanol
parent c1a5a7504e
commit 72ffabf619
5 changed files with 63 additions and 21 deletions

View File

@@ -11,7 +11,13 @@ class Admin::EmailController < Admin::AdminController
params.require(:email_address)
begin
Jobs::TestEmail.new.execute(to_address: params[:email_address])
render body: nil
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
rescue => e
render json: { errors: [e.message] }, status: 422
end