A platform for community discussion. Free, open, simple.
FIX: Staff action log logs in default locale when a user deletes themselves (#32503)
Natalie Tayb990df657001
diff --git a/app/services/user_destroyer.rb b/app/services/user_destroyer.rbindex 15bd0bb5e43..23a697a5186 100644--- a/app/services/user_destroyer.rb+++ b/app/services/user_destroyer.rb@@ -97,7 +97,11 @@ class UserDestroyerunless opts[:quiet]if @actor == userdeleted_by = Discourse.system_user- opts[:context] = I18n.t("staff_action_logs.user_delete_self", url: opts[:context])+ message =+ I18n.with_locale(SiteSetting.default_locale) do+ I18n.t("staff_action_logs.user_delete_self", url: opts[:context])+ end+ opts[:context] = messageelsedeleted_by = @actorenddiff --git a/spec/services/user_destroyer_spec.rb b/spec/services/user_destroyer_spec.rbindex 36aaa5b1889..866a6fb603f 100644--- a/spec/services/user_destroyer_spec.rb+++ b/spec/services/user_destroyer_spec.rb@@ -81,10 +81,15 @@ RSpec.describe UserDestroyer doinclude_examples "successfully destroy a user"- it "should log proper context" do+ it "logs context in default locale" do+ I18n.locale = :ja+ SiteSetting.default_locale = :de+destroyexpect(UserHistory.where(action: UserHistory.actions[:delete_user]).last.context).to eq(- I18n.t("staff_action_logs.user_delete_self", url: "/u/username/preferences/account"),+ I18n.with_locale(:de) do+ I18n.t("staff_action_logs.user_delete_self", url: "/u/username/preferences/account")+ end,)endend