Merge branch 'main' into glitch-soc/merge-upstream
This commit is contained in:
@ -117,6 +117,16 @@ module Admin
|
||||
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.removed_header_msg', username: @account.acct)
|
||||
end
|
||||
|
||||
def unblock_email
|
||||
authorize @account, :unblock_email?
|
||||
|
||||
CanonicalEmailBlock.where(reference_account: @account).delete_all
|
||||
|
||||
log_action :unblock_email, @account
|
||||
|
||||
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.unblocked_email_msg', username: @account.acct)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
|
@ -14,6 +14,15 @@ module Admin
|
||||
authorize :instance, :show?
|
||||
end
|
||||
|
||||
def destroy
|
||||
authorize :instance, :destroy?
|
||||
|
||||
Admin::DomainPurgeWorker.perform_async(@instance.domain)
|
||||
|
||||
log_action :destroy, @instance
|
||||
redirect_to admin_instances_path, notice: I18n.t('admin.instances.destroyed_msg', domain: @instance.domain)
|
||||
end
|
||||
|
||||
def clear_delivery_errors
|
||||
authorize :delivery, :clear_delivery_errors?
|
||||
|
||||
|
@ -31,6 +31,8 @@ module Admin::ActionLogsHelper
|
||||
link_to truncate(record.text), edit_admin_announcement_path(record.id)
|
||||
when 'IpBlock'
|
||||
"#{record.ip}/#{record.ip.prefix} (#{I18n.t("simple_form.labels.ip_block.severities.#{record.severity}")})"
|
||||
when 'Instance'
|
||||
record.domain
|
||||
end
|
||||
end
|
||||
|
||||
@ -54,6 +56,8 @@ module Admin::ActionLogsHelper
|
||||
truncate(attributes['text'].is_a?(Array) ? attributes['text'].last : attributes['text'])
|
||||
when 'IpBlock'
|
||||
"#{attributes['ip']}/#{attributes['ip'].prefix} (#{I18n.t("simple_form.labels.ip_block.severities.#{attributes['severity']}")})"
|
||||
when 'Instance'
|
||||
attributes['domain']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -42,6 +42,7 @@ export default class Retention extends React.PureComponent {
|
||||
|
||||
render () {
|
||||
const { loading, data } = this.state;
|
||||
const { frequency } = this.props;
|
||||
|
||||
let content;
|
||||
|
||||
@ -129,9 +130,18 @@ export default class Retention extends React.PureComponent {
|
||||
);
|
||||
}
|
||||
|
||||
let title = null;
|
||||
switch(frequency) {
|
||||
case 'day':
|
||||
title = <FormattedMessage id='admin.dashboard.daily_retention' defaultMessage='User retention rate by day after sign-up' />;
|
||||
break;
|
||||
default:
|
||||
title = <FormattedMessage id='admin.dashboard.monthly_retention' defaultMessage='User retention rate by month after sign-up' />;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='retention'>
|
||||
<h4><FormattedMessage id='admin.dashboard.retention' defaultMessage='Retention' /></h4>
|
||||
<h4>{title}</h4>
|
||||
|
||||
{content}
|
||||
</div>
|
||||
|
@ -3074,17 +3074,20 @@ a.account__display-name {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
color: $inverted-text-color;
|
||||
background: $simple-background-color;
|
||||
padding: 10px;
|
||||
color: $darker-text-color;
|
||||
background: transparent;
|
||||
padding: 7px 0;
|
||||
font-family: inherit;
|
||||
font-size: 14px;
|
||||
resize: vertical;
|
||||
border: 0;
|
||||
border-bottom: 2px solid $ui-primary-color;
|
||||
outline: 0;
|
||||
border-radius: 4px;
|
||||
|
||||
&:focus {
|
||||
&:focus,
|
||||
&:active {
|
||||
color: $primary-text-color;
|
||||
border-bottom-color: $ui-highlight-color;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ class Admin::ActionLogFilter
|
||||
destroy_domain_allow: { target_type: 'DomainAllow', action: 'destroy' }.freeze,
|
||||
destroy_domain_block: { target_type: 'DomainBlock', action: 'destroy' }.freeze,
|
||||
destroy_email_domain_block: { target_type: 'EmailDomainBlock', action: 'destroy' }.freeze,
|
||||
destroy_instance: { target_type: 'Instance', action: 'destroy' }.freeze,
|
||||
destroy_unavailable_domain: { target_type: 'UnavailableDomain', action: 'destroy' }.freeze,
|
||||
destroy_status: { target_type: 'Status', action: 'destroy' }.freeze,
|
||||
disable_2fa_user: { target_type: 'User', action: 'disable' }.freeze,
|
||||
@ -49,6 +50,7 @@ class Admin::ActionLogFilter
|
||||
update_announcement: { target_type: 'Announcement', action: 'update' }.freeze,
|
||||
update_custom_emoji: { target_type: 'CustomEmoji', action: 'update' }.freeze,
|
||||
update_status: { target_type: 'Status', action: 'update' }.freeze,
|
||||
unblock_email_account: { target_type: 'Account', action: 'unblock_email' }.freeze,
|
||||
}.freeze
|
||||
|
||||
attr_reader :params
|
||||
|
@ -24,4 +24,8 @@ class CanonicalEmailBlock < ApplicationRecord
|
||||
def self.block?(email)
|
||||
where(canonical_email_hash: email_to_canonical_email_hash(email)).exists?
|
||||
end
|
||||
|
||||
def self.find_blocks(email)
|
||||
where(canonical_email_hash: email_to_canonical_email_hash(email))
|
||||
end
|
||||
end
|
||||
|
@ -64,4 +64,8 @@ class AccountPolicy < ApplicationPolicy
|
||||
def memorialize?
|
||||
admin? && !record.user&.admin? && !record.instance_actor?
|
||||
end
|
||||
|
||||
def unblock_email?
|
||||
staff?
|
||||
end
|
||||
end
|
||||
|
@ -8,4 +8,8 @@ class InstancePolicy < ApplicationPolicy
|
||||
def show?
|
||||
admin?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
admin?
|
||||
end
|
||||
end
|
||||
|
10
app/services/purge_domain_service.rb
Normal file
10
app/services/purge_domain_service.rb
Normal file
@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PurgeDomainService < BaseService
|
||||
def call(domain)
|
||||
Account.remote.where(domain: domain).reorder(nil).find_each do |account|
|
||||
DeleteAccountService.new.call(account, reserve_username: false, skip_side_effects: true)
|
||||
end
|
||||
Instance.refresh
|
||||
end
|
||||
end
|
@ -71,7 +71,9 @@
|
||||
= t('admin.accounts.no_limits_imposed')
|
||||
.dashboard__counters__label= t 'admin.accounts.login_status'
|
||||
|
||||
- unless @account.local? && @account.user.nil?
|
||||
- if @account.local? && @account.user.nil?
|
||||
= link_to t('admin.accounts.unblock_email'), unblock_email_admin_account_path(@account.id), method: :post, class: 'button' if can?(:unblock_email, @account) && CanonicalEmailBlock.where(reference_account_id: @account.id).exists?
|
||||
- else
|
||||
.table-wrapper
|
||||
%table.table.inline-table
|
||||
%tbody
|
||||
|
@ -84,3 +84,5 @@
|
||||
= link_to t('admin.instances.delivery.stop'), stop_delivery_admin_instance_path(@instance), data: { confirm: t('admin.accounts.are_you_sure'), method: :post }, class: 'button'
|
||||
- else
|
||||
= link_to t('admin.instances.delivery.restart'), restart_delivery_admin_instance_path(@instance), data: { confirm: t('admin.accounts.are_you_sure'), method: :post }, class: 'button'
|
||||
- unless @instance.delivery_failure_tracker.available? && @instance.accounts_count > 0
|
||||
= link_to t('admin.instances.purge'), admin_instance_path(@instance), data: { confirm: t('admin.instances.confirm_purge'), method: :delete }, class: 'button'
|
||||
|
9
app/workers/admin/domain_purge_worker.rb
Normal file
9
app/workers/admin/domain_purge_worker.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Admin::DomainPurgeWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(domain)
|
||||
PurgeDomainService.new.call(domain)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user