mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Reinstate action logging (#38211)
This commit is contained in:
@@ -46,6 +46,7 @@ class Admin::AccountAction < Admin::BaseAction
|
||||
ApplicationRecord.transaction do
|
||||
handle_type!
|
||||
process_strike!
|
||||
create_log!
|
||||
process_reports!
|
||||
end
|
||||
|
||||
@@ -105,6 +106,12 @@ class Admin::AccountAction < Admin::BaseAction
|
||||
target_account.suspend!(origin: :local)
|
||||
end
|
||||
|
||||
def create_log!
|
||||
# A log entry is only interesting if the warning contains
|
||||
# custom text from someone. Otherwise it's just noise.
|
||||
log_action(:create, @warning) if @warning&.text.present? && type == 'none'
|
||||
end
|
||||
|
||||
def text_for_warning
|
||||
[warning_preset&.text, text].compact.join("\n\n")
|
||||
end
|
||||
|
||||
@@ -11,12 +11,14 @@ RSpec.describe Admin::AccountAction do
|
||||
let(:account) { Fabricate(:admin_user).account }
|
||||
let(:target_account) { Fabricate(:account) }
|
||||
let(:type) { 'disable' }
|
||||
let(:text) { nil }
|
||||
|
||||
before do
|
||||
account_action.assign_attributes(
|
||||
type: type,
|
||||
current_account: account,
|
||||
target_account: target_account
|
||||
target_account: target_account,
|
||||
text:
|
||||
)
|
||||
end
|
||||
|
||||
@@ -53,6 +55,20 @@ RSpec.describe Admin::AccountAction do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when type is `none`' do
|
||||
let(:type) { 'none' }
|
||||
|
||||
context 'when a custom text is given' do
|
||||
let(:text) { 'custom' }
|
||||
|
||||
it 'logs the action' do
|
||||
expect { subject }.to change(Admin::ActionLog, :count).by(1)
|
||||
|
||||
expect(Admin::ActionLog.last.target.text).to eq 'custom'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when type is invalid' do
|
||||
let(:type) { 'whatever' }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user