mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 08:52:46 +08:00
FIX: improve context when user deletes self
This commit is contained in:
parent
3f167ae5ce
commit
f1d1207725
|
@ -81,9 +81,14 @@ class UserDestroyer
|
|||
end
|
||||
|
||||
unless opts[:quiet]
|
||||
StaffActionLogger.new(@actor == user ? Discourse.system_user : @actor).log_user_deletion(user, opts.slice(:context))
|
||||
if @actor == user
|
||||
deleted_by = Discourse.system_user
|
||||
opts[:context] = I18n.t("staff_action_logs.user_delete_self", url: opts[:context])
|
||||
else
|
||||
deleted_by = @actor
|
||||
end
|
||||
StaffActionLogger.new(deleted_by).log_user_deletion(user, opts.slice(:context))
|
||||
end
|
||||
|
||||
MessageBus.publish "/file-change", ["refresh"], user_ids: [u.id]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3897,3 +3897,4 @@ en:
|
|||
not_found: "not found"
|
||||
unknown: "unknown"
|
||||
user_merged: "%{username} was merged into this account"
|
||||
user_delete_self: "Deleted by self from %{url}"
|
||||
|
|
|
@ -71,10 +71,15 @@ describe UserDestroyer do
|
|||
end
|
||||
|
||||
context 'user deletes self' do
|
||||
let(:destroy_opts) { { delete_posts: true } }
|
||||
let(:destroy_opts) { { delete_posts: true, context: "/u/username/preferences/account" } }
|
||||
subject(:destroy) { UserDestroyer.new(@user).destroy(@user, destroy_opts) }
|
||||
|
||||
include_examples "successfully destroy a user"
|
||||
|
||||
it 'should log proper context' do
|
||||
destroy
|
||||
expect(UserHistory.where(action: UserHistory.actions[:delete_user]).last.context).to eq(I18n.t("staff_action_logs.user_delete_self", url: "/u/username/preferences/account"))
|
||||
end
|
||||
end
|
||||
|
||||
context "with a queued post" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user