Add option to block reports from domain (#8830)
parent
d5bfba3262
commit
fd5285658f
|
@ -46,7 +46,7 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def resource_params
|
def resource_params
|
||||||
params.require(:domain_block).permit(:domain, :severity, :reject_media, :retroactive)
|
params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_reports, :retroactive)
|
||||||
end
|
end
|
||||||
|
|
||||||
def retroactive_unblock?
|
def retroactive_unblock?
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
import { delegate } from 'rails-ujs';
|
import { delegate } from 'rails-ujs';
|
||||||
|
|
||||||
function handleDeleteStatus(event) {
|
|
||||||
const [data] = event.detail;
|
|
||||||
const element = document.querySelector(`[data-id="${data.id}"]`);
|
|
||||||
if (element) {
|
|
||||||
element.parentNode.removeChild(element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[].forEach.call(document.querySelectorAll('.trash-button'), (content) => {
|
|
||||||
content.addEventListener('ajax:success', handleDeleteStatus);
|
|
||||||
});
|
|
||||||
|
|
||||||
const batchCheckboxClassName = '.batch-checkbox input[type="checkbox"]';
|
const batchCheckboxClassName = '.batch-checkbox input[type="checkbox"]';
|
||||||
|
|
||||||
delegate(document, '#batch_checkbox_all', 'change', ({ target }) => {
|
delegate(document, '#batch_checkbox_all', 'change', ({ target }) => {
|
||||||
|
@ -22,6 +10,7 @@ delegate(document, '#batch_checkbox_all', 'change', ({ target }) => {
|
||||||
|
|
||||||
delegate(document, batchCheckboxClassName, 'change', () => {
|
delegate(document, batchCheckboxClassName, 'change', () => {
|
||||||
const checkAllElement = document.querySelector('#batch_checkbox_all');
|
const checkAllElement = document.querySelector('#batch_checkbox_all');
|
||||||
|
|
||||||
if (checkAllElement) {
|
if (checkAllElement) {
|
||||||
checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
|
checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
|
||||||
checkAllElement.indeterminate = !checkAllElement.checked && [].some.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
|
checkAllElement.indeterminate = !checkAllElement.checked && [].some.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
|
||||||
|
@ -41,8 +30,14 @@ delegate(document, '.media-spoiler-hide-button', 'click', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
delegate(document, '#domain_block_severity', 'change', ({ target }) => {
|
delegate(document, '#domain_block_severity', 'change', ({ target }) => {
|
||||||
const rejectMediaDiv = document.querySelector('.input.with_label.domain_block_reject_media');
|
const rejectMediaDiv = document.querySelector('.input.with_label.domain_block_reject_media');
|
||||||
|
const rejectReportsDiv = document.querySelector('.input.with_label.domain_block_reject_reports');
|
||||||
|
|
||||||
if (rejectMediaDiv) {
|
if (rejectMediaDiv) {
|
||||||
rejectMediaDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
|
rejectMediaDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rejectReportsDiv) {
|
||||||
|
rejectReportsDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
class ActivityPub::Activity::Flag < ActivityPub::Activity
|
class ActivityPub::Activity::Flag < ActivityPub::Activity
|
||||||
def perform
|
def perform
|
||||||
|
return if skip_reports?
|
||||||
|
|
||||||
target_accounts = object_uris.map { |uri| account_from_uri(uri) }.compact.select(&:local?)
|
target_accounts = object_uris.map { |uri| account_from_uri(uri) }.compact.select(&:local?)
|
||||||
target_statuses_by_account = object_uris.map { |uri| status_from_uri(uri) }.compact.select(&:local?).group_by(&:account_id)
|
target_statuses_by_account = object_uris.map { |uri| status_from_uri(uri) }.compact.select(&:local?).group_by(&:account_id)
|
||||||
|
|
||||||
|
@ -19,6 +21,12 @@ class ActivityPub::Activity::Flag < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def skip_reports?
|
||||||
|
DomainBlock.find_by(domain: @account.domain)&.reject_reports?
|
||||||
|
end
|
||||||
|
|
||||||
def object_uris
|
def object_uris
|
||||||
@object_uris ||= Array(@object.is_a?(Array) ? @object.map { |item| value_or_id(item) } : value_or_id(@object))
|
@object_uris ||= Array(@object.is_a?(Array) ? @object.map { |item| value_or_id(item) } : value_or_id(@object))
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
#
|
#
|
||||||
# Table name: domain_blocks
|
# Table name: domain_blocks
|
||||||
#
|
#
|
||||||
# id :bigint(8) not null, primary key
|
# id :bigint(8) not null, primary key
|
||||||
# domain :string default(""), not null
|
# domain :string default(""), not null
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# severity :integer default("silence")
|
# severity :integer default("silence")
|
||||||
# reject_media :boolean default(FALSE), not null
|
# reject_media :boolean default(FALSE), not null
|
||||||
|
# reject_reports :boolean default(FALSE), not null
|
||||||
#
|
#
|
||||||
|
|
||||||
class DomainBlock < ApplicationRecord
|
class DomainBlock < ApplicationRecord
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
%tr
|
%tr
|
||||||
%td.domain
|
%td
|
||||||
%samp= domain_block.domain
|
%samp= domain_block.domain
|
||||||
%td.severity
|
%td.severity
|
||||||
= t("admin.domain_blocks.severities.#{domain_block.severity}")
|
= t("admin.domain_blocks.severities.#{domain_block.severity}")
|
||||||
%td.reject_media
|
%td.reject_media
|
||||||
- if domain_block.reject_media? || domain_block.suspend?
|
- if domain_block.reject_media? || domain_block.suspend?
|
||||||
%i.fa.fa-check
|
%i.fa.fa-check
|
||||||
|
%td.reject_reports
|
||||||
|
- if domain_block.reject_reports? || domain_block.suspend?
|
||||||
|
%i.fa.fa-check
|
||||||
%td
|
%td
|
||||||
= table_link_to 'undo', t('admin.domain_blocks.undo'), admin_domain_block_path(domain_block)
|
= table_link_to 'undo', t('admin.domain_blocks.undo'), admin_domain_block_path(domain_block)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
%th= t('admin.domain_blocks.domain')
|
%th= t('admin.domain_blocks.domain')
|
||||||
%th= t('admin.domain_blocks.severity')
|
%th= t('admin.domain_blocks.severity')
|
||||||
%th= t('admin.domain_blocks.reject_media')
|
%th= t('admin.domain_blocks.reject_media')
|
||||||
|
%th= t('admin.domain_blocks.reject_reports')
|
||||||
%th
|
%th
|
||||||
%tbody
|
%tbody
|
||||||
= render @domain_blocks
|
= render @domain_blocks
|
||||||
|
|
|
@ -17,5 +17,8 @@
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :reject_media, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_media'), hint: I18n.t('admin.domain_blocks.reject_media_hint')
|
= f.input :reject_media, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_media'), hint: I18n.t('admin.domain_blocks.reject_media_hint')
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= f.input :reject_reports, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reports'), hint: I18n.t('admin.domain_blocks.reject_reports_hint')
|
||||||
|
|
||||||
.actions
|
.actions
|
||||||
= f.button :button, t('.create'), type: :submit
|
= f.button :button, t('.create'), type: :submit
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%tr
|
%tr
|
||||||
%td.domain
|
%td
|
||||||
%samp= email_domain_block.domain
|
%samp= email_domain_block.domain
|
||||||
%td
|
%td
|
||||||
= table_link_to 'trash', t('admin.email_domain_blocks.delete'), admin_email_domain_block_path(email_domain_block), method: :delete
|
= table_link_to 'trash', t('admin.email_domain_blocks.delete'), admin_email_domain_block_path(email_domain_block), method: :delete
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%tr
|
%tr
|
||||||
%td.domain
|
%td
|
||||||
= link_to instance.domain, admin_accounts_path(by_domain: instance.domain)
|
= link_to instance.domain, admin_accounts_path(by_domain: instance.domain)
|
||||||
%td.count
|
%td.count
|
||||||
= instance.accounts_count
|
= instance.accounts_count
|
||||||
|
|
|
@ -263,6 +263,8 @@ en:
|
||||||
title: New domain block
|
title: New domain block
|
||||||
reject_media: Reject media files
|
reject_media: Reject media files
|
||||||
reject_media_hint: Removes locally stored media files and refuses to download any in the future. Irrelevant for suspensions
|
reject_media_hint: Removes locally stored media files and refuses to download any in the future. Irrelevant for suspensions
|
||||||
|
reject_reports: Reject reports
|
||||||
|
reject_reports_hint: Ignore all reports coming from this domain. Irrelevant for suspensions
|
||||||
severities:
|
severities:
|
||||||
noop: None
|
noop: None
|
||||||
silence: Silence
|
silence: Silence
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||||
|
|
||||||
|
class AddRejectReportsToDomainBlocks < ActiveRecord::Migration[5.2]
|
||||||
|
include Mastodon::MigrationHelpers
|
||||||
|
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def up
|
||||||
|
safety_assured do
|
||||||
|
add_column_with_default :domain_blocks, :reject_reports, :boolean, default: false, allow_null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_column :domain_blocks, :reject_reports
|
||||||
|
end
|
||||||
|
end
|
|
@ -186,6 +186,7 @@ ActiveRecord::Schema.define(version: 2018_10_18_205649) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.integer "severity", default: 0
|
t.integer "severity", default: 0
|
||||||
t.boolean "reject_media", default: false, null: false
|
t.boolean "reject_media", default: false, null: false
|
||||||
|
t.boolean "reject_reports", default: false, null: false
|
||||||
t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
|
t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Reference in New Issue