mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Fix inability to locally suspend remotely-suspended accounts in moderation interface (#31899)
This commit is contained in:
parent
a2c4f5f5c0
commit
ba81e4e019
@ -259,6 +259,10 @@ class Account < ApplicationRecord
|
|||||||
suspended_at.present? && !instance_actor?
|
suspended_at.present? && !instance_actor?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def suspended_locally?
|
||||||
|
suspended? && suspension_origin_local?
|
||||||
|
end
|
||||||
|
|
||||||
def suspended_permanently?
|
def suspended_permanently?
|
||||||
suspended? && deletion_request.nil?
|
suspended? && deletion_request.nil?
|
||||||
end
|
end
|
||||||
|
@ -74,7 +74,7 @@ class Admin::AccountAction
|
|||||||
end
|
end
|
||||||
|
|
||||||
def disabled_types_for_account(account)
|
def disabled_types_for_account(account)
|
||||||
if account.suspended?
|
if account.suspended_locally?
|
||||||
%w(silence suspend)
|
%w(silence suspend)
|
||||||
elsif account.silenced?
|
elsif account.silenced?
|
||||||
%w(silence)
|
%w(silence)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('admin.account_actions.title', acct: @account.pretty_acct)
|
= t('admin.account_actions.title', acct: @account.pretty_acct)
|
||||||
|
|
||||||
- if @account.suspended?
|
- if @account.suspended_locally?
|
||||||
.flash-message.alert
|
.flash-message.alert
|
||||||
= t('admin.account_actions.already_suspended')
|
= t('admin.account_actions.already_suspended')
|
||||||
- elsif @account.silenced?
|
- elsif @account.silenced?
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
= form.button t('admin.accounts.silence'),
|
= form.button t('admin.accounts.silence'),
|
||||||
name: :silence,
|
name: :silence,
|
||||||
class: 'button button--destructive',
|
class: 'button button--destructive',
|
||||||
disabled: report.target_account.silenced? || report.target_account.suspended?,
|
disabled: report.target_account.silenced? || report.target_account.suspended_locally?,
|
||||||
title: report.target_account.silenced? ? t('admin.account_actions.already_silenced') : ''
|
title: report.target_account.silenced? ? t('admin.account_actions.already_silenced') : ''
|
||||||
.report-actions__item__description
|
.report-actions__item__description
|
||||||
= t('admin.reports.actions.silence_description_html')
|
= t('admin.reports.actions.silence_description_html')
|
||||||
@ -36,8 +36,8 @@
|
|||||||
= form.button t('admin.accounts.suspend'),
|
= form.button t('admin.accounts.suspend'),
|
||||||
name: :suspend,
|
name: :suspend,
|
||||||
class: 'button button--destructive',
|
class: 'button button--destructive',
|
||||||
disabled: report.target_account.suspended?,
|
disabled: report.target_account.suspended_locally?,
|
||||||
title: report.target_account.suspended? ? t('admin.account_actions.already_suspended') : ''
|
title: report.target_account.suspended_locally? ? t('admin.account_actions.already_suspended') : ''
|
||||||
.report-actions__item__description
|
.report-actions__item__description
|
||||||
= t('admin.reports.actions.suspend_description_html')
|
= t('admin.reports.actions.suspend_description_html')
|
||||||
.report-actions__item
|
.report-actions__item
|
||||||
|
@ -10,10 +10,39 @@ RSpec.describe Account do
|
|||||||
|
|
||||||
let(:bob) { Fabricate(:account, username: 'bob') }
|
let(:bob) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
|
describe '#suspended_locally?' do
|
||||||
|
context 'when the account is not suspended' do
|
||||||
|
it 'returns false' do
|
||||||
|
expect(subject.suspended_locally?).to be false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the account is suspended locally' do
|
||||||
|
before do
|
||||||
|
subject.update!(suspended_at: 1.day.ago, suspension_origin: :local)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true' do
|
||||||
|
expect(subject.suspended_locally?).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the account is suspended remotely' do
|
||||||
|
before do
|
||||||
|
subject.update!(suspended_at: 1.day.ago, suspension_origin: :remote)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns false' do
|
||||||
|
expect(subject.suspended_locally?).to be false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#suspend!' do
|
describe '#suspend!' do
|
||||||
it 'marks the account as suspended and creates a deletion request' do
|
it 'marks the account as suspended and creates a deletion request' do
|
||||||
expect { subject.suspend! }
|
expect { subject.suspend! }
|
||||||
.to change(subject, :suspended?).from(false).to(true)
|
.to change(subject, :suspended?).from(false).to(true)
|
||||||
|
.and change(subject, :suspended_locally?).from(false).to(true)
|
||||||
.and(change { AccountDeletionRequest.exists?(account: subject) }.from(false).to(true))
|
.and(change { AccountDeletionRequest.exists?(account: subject) }.from(false).to(true))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user