Add domain block setting reject_favourite and reject_reply
This commit is contained in:
parent
27353bbaee
commit
6537405eab
15 changed files with 85 additions and 22 deletions
|
@ -78,15 +78,15 @@ module Admin
|
|||
end
|
||||
|
||||
def update_params
|
||||
params.require(:domain_block).permit(:severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
||||
params.require(:domain_block).permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
||||
params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
||||
end
|
||||
|
||||
def form_domain_block_batch_params
|
||||
params.require(:form_domain_block_batch).permit(domain_blocks_attributes: [:enabled, :domain, :severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate])
|
||||
params.require(:form_domain_block_batch).permit(domain_blocks_attributes: [:enabled, :domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reports, :private_comment, :public_comment, :obfuscate])
|
||||
end
|
||||
|
||||
def action_from_button
|
||||
|
|
|
@ -69,7 +69,7 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
|
|||
end
|
||||
|
||||
def domain_block_params
|
||||
params.permit(:severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
||||
params.permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
|
@ -101,6 +101,6 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
|
|||
end
|
||||
|
||||
def resource_params
|
||||
params.permit(:domain, :severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
||||
params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reports, :private_comment, :public_comment, :obfuscate)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -108,12 +108,22 @@ delegate(document, '.filter-subset--with-select select', 'change', ({ target })
|
|||
|
||||
const onDomainBlockSeverityChange = (target) => {
|
||||
const rejectMediaDiv = document.querySelector('.input.with_label.domain_block_reject_media');
|
||||
const rejectFavouriteDiv= document.querySelector('.input.with_label.domain_block_reject_favourite');
|
||||
const rejectReplyDiv = document.querySelector('.input.with_label.domain_block_reject_reply');
|
||||
const rejectReportsDiv = document.querySelector('.input.with_label.domain_block_reject_reports');
|
||||
|
||||
if (rejectMediaDiv) {
|
||||
rejectMediaDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
|
||||
}
|
||||
|
||||
if (rejectFavouriteDiv) {
|
||||
rejectFavouriteDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
|
||||
}
|
||||
|
||||
if (rejectReplyDiv) {
|
||||
rejectReplyDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
|
||||
}
|
||||
|
||||
if (rejectReportsDiv) {
|
||||
rejectReportsDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
|
||||
def create_status
|
||||
return reject_payload! if unsupported_object_type? || non_matching_uri_hosts?(@account.uri, object_uri) || tombstone_exists? || !related_to_local_activity?
|
||||
return reject_payload! if reply_to_local? && reject_reply_to_local?
|
||||
|
||||
with_lock("create:#{object_uri}") do
|
||||
return if delete_arrived_first?(object_uri) || poll_vote?
|
||||
|
@ -392,6 +393,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
!replied_to_status.nil? && replied_to_status.account.local?
|
||||
end
|
||||
|
||||
def reject_reply_to_local?
|
||||
@reject_reply_to_local ||= DomainBlock.reject_reply?(@account.domain)
|
||||
end
|
||||
|
||||
def related_to_local_activity?
|
||||
fetch? || followed_by_local_accounts? || requested_through_relay? ||
|
||||
responds_to_followed_account? || addresses_local_accounts?
|
||||
|
|
|
@ -4,7 +4,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
|||
def perform
|
||||
@original_status = status_from_uri(object_uri)
|
||||
|
||||
return if @original_status.nil? || !@original_status.account.local? || delete_arrived_first?(@json['id'])
|
||||
return if @original_status.nil? || !@original_status.account.local? || delete_arrived_first?(@json['id']) || reject_favourite?
|
||||
|
||||
if shortcode.nil?
|
||||
process_favourite
|
||||
|
@ -15,6 +15,10 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
|||
|
||||
private
|
||||
|
||||
def reject_favourite?
|
||||
@reject_favourite ||= DomainBlock.reject_favourite?(@account.domain)
|
||||
end
|
||||
|
||||
def process_favourite
|
||||
return if @account.favourited?(@original_status)
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Admin::Import
|
|||
field&.strip
|
||||
when '#severity'
|
||||
field&.strip&.to_sym
|
||||
when '#reject_media', '#reject_reports', '#obfuscate'
|
||||
when '#reject_media', '#reject_favourite', '#reject_reply', '#reject_reports', '#obfuscate'
|
||||
ActiveModel::Type::Boolean.new.cast(field)
|
||||
else
|
||||
field
|
||||
|
|
|
@ -4,16 +4,18 @@
|
|||
#
|
||||
# Table name: domain_blocks
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# domain :string default(""), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# severity :integer default("silence")
|
||||
# reject_media :boolean default(FALSE), not null
|
||||
# reject_reports :boolean default(FALSE), not null
|
||||
# private_comment :text
|
||||
# public_comment :text
|
||||
# obfuscate :boolean default(FALSE), not null
|
||||
# id :bigint(8) not null, primary key
|
||||
# domain :string default(""), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# severity :integer default("silence")
|
||||
# reject_media :boolean default(FALSE), not null
|
||||
# reject_reports :boolean default(FALSE), not null
|
||||
# private_comment :text
|
||||
# public_comment :text
|
||||
# obfuscate :boolean default(FALSE), not null
|
||||
# reject_favourite :boolean default(FALSE), not null
|
||||
# reject_reply :boolean default(FALSE), not null
|
||||
#
|
||||
|
||||
class DomainBlock < ApplicationRecord
|
||||
|
@ -30,7 +32,7 @@ class DomainBlock < ApplicationRecord
|
|||
|
||||
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
|
||||
scope :with_user_facing_limitations, -> { where(severity: [:silence, :suspend]) }
|
||||
scope :with_limitations, -> { where(severity: [:silence, :suspend]).or(where(reject_media: true)) }
|
||||
scope :with_limitations, -> { where(severity: [:silence, :suspend]).or(where(reject_media: true)).or(where(reject_favourite: true)).or(where(reject_reply: true)) }
|
||||
scope :by_severity, -> { order(Arel.sql('(CASE severity WHEN 0 THEN 1 WHEN 1 THEN 2 WHEN 2 THEN 0 END), domain')) }
|
||||
|
||||
def to_log_human_identifier
|
||||
|
@ -41,7 +43,7 @@ class DomainBlock < ApplicationRecord
|
|||
if suspend?
|
||||
[:suspend]
|
||||
else
|
||||
[severity.to_sym, reject_media? ? :reject_media : nil, reject_reports? ? :reject_reports : nil].reject { |policy| policy == :noop || policy.nil? }
|
||||
[severity.to_sym, reject_media? ? :reject_media : nil, reject_favourite? ? :reject_favourite : nil, reject_reply? ? :reject_reply : nil, reject_reports? ? :reject_reports : nil].reject { |policy| policy == :noop || policy.nil? }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -58,6 +60,14 @@ class DomainBlock < ApplicationRecord
|
|||
!!rule_for(domain)&.reject_media?
|
||||
end
|
||||
|
||||
def reject_favourite?(domain)
|
||||
!!rule_for(domain)&.reject_favourite?
|
||||
end
|
||||
|
||||
def reject_reply?(domain)
|
||||
!!rule_for(domain)&.reject_reply?
|
||||
end
|
||||
|
||||
def reject_reports?(domain)
|
||||
!!rule_for(domain)&.reject_reports?
|
||||
end
|
||||
|
@ -82,7 +92,7 @@ class DomainBlock < ApplicationRecord
|
|||
return false if other_block.suspend? && (silence? || noop?)
|
||||
return false if other_block.silence? && noop?
|
||||
|
||||
(reject_media || !other_block.reject_media) && (reject_reports || !other_block.reject_reports)
|
||||
(reject_media || !other_block.reject_media) && (reject_favourite || !other_block.reject_favourite) && (reject_reply || !other_block.reject_reply) && (reject_reports || !other_block.reject_reports)
|
||||
end
|
||||
|
||||
def affected_accounts_count
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class REST::Admin::DomainBlockSerializer < ActiveModel::Serializer
|
||||
attributes :id, :domain, :created_at, :severity,
|
||||
:reject_media, :reject_reports,
|
||||
:reject_media, :reject_favourite, :reject_reply, :reject_reports,
|
||||
:private_comment, :public_comment, :obfuscate
|
||||
|
||||
def id
|
||||
|
|
|
@ -17,6 +17,12 @@
|
|||
.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')
|
||||
|
||||
.fields-group
|
||||
= f.input :reject_favourite, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_favourite'), hint: I18n.t('admin.domain_blocks.reject_favourite_hint')
|
||||
|
||||
.fields-group
|
||||
= f.input :reject_reply, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reply'), hint: I18n.t('admin.domain_blocks.reject_reply_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')
|
||||
|
||||
|
|
|
@ -17,6 +17,12 @@
|
|||
.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')
|
||||
|
||||
.fields-group
|
||||
= f.input :reject_favourite, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_favourite'), hint: I18n.t('admin.domain_blocks.reject_favourite_hint')
|
||||
|
||||
.fields-group
|
||||
= f.input :reject_reply, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reply'), hint: I18n.t('admin.domain_blocks.reject_reply_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')
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
= f.hidden_field :domain
|
||||
= f.hidden_field :severity
|
||||
= f.hidden_field :reject_media
|
||||
= f.hidden_field :reject_favourite
|
||||
= f.hidden_field :reject_reply
|
||||
= f.hidden_field :reject_reports
|
||||
= f.hidden_field :obfuscate
|
||||
= f.hidden_field :private_comment
|
||||
|
|
|
@ -412,8 +412,12 @@ en:
|
|||
private_comment_hint: Comment about this domain limitation for internal use by the moderators.
|
||||
public_comment: Public comment
|
||||
public_comment_hint: Comment about this domain limitation for the general public, if advertising the list of domain limitations is enabled.
|
||||
reject_favourite: Reject favourites
|
||||
reject_favourite_hint: Reject favourites or emoji-reaction in the future
|
||||
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_reply: Reject replies
|
||||
reject_reply_hint: Reject replies in the future
|
||||
reject_reports: Reject reports
|
||||
reject_reports_hint: Ignore all reports coming from this domain. Irrelevant for suspensions
|
||||
undo: Undo domain block
|
||||
|
@ -483,7 +487,9 @@ en:
|
|||
description_html: You can define content policies that will be applied to all accounts from this domain and any of its subdomains.
|
||||
limited_federation_mode_description_html: You can chose whether to allow federation with this domain.
|
||||
policies:
|
||||
reject_favourite: Reject favourite
|
||||
reject_media: Reject media
|
||||
reject_reply: Reject reply
|
||||
reject_reports: Reject reports
|
||||
silence: Limit
|
||||
suspend: Suspend
|
||||
|
|
|
@ -403,8 +403,12 @@ ja:
|
|||
private_comment_hint: このコメントは同じサーバーのモデレーターも閲覧できます。
|
||||
public_comment: コメント (公開)
|
||||
public_comment_hint: ドメインブロックの公開を有効にしている場合、このコメントも公開されます。
|
||||
reject_favourite: お気に入り、絵文字リアクションを拒否
|
||||
reject_favourite_hint: 今後のお気に入り、絵文字リアクションを拒否します。停止とは無関係です
|
||||
reject_media: メディアファイルを拒否
|
||||
reject_media_hint: ローカルに保存されたメディアファイルを削除し、今後のダウンロードを拒否します。停止とは無関係です
|
||||
reject_reply: リプライを拒否
|
||||
reject_reply_hint: 今後のリプライを拒否します。停止とは無関係です
|
||||
reject_reports: 通報を拒否
|
||||
reject_reports_hint: このドメインからの通報をすべて無視します。停止とは無関係です
|
||||
undo: ドメインブロックを戻す
|
||||
|
@ -471,7 +475,9 @@ ja:
|
|||
description_html: このドメインとそのサブドメインのすべてのアカウントに適用されるコンテンツポリシーを定義できます。
|
||||
limited_federation_mode_description_html: このドメインとの連合を許可するかどうかを選択できます。
|
||||
policies:
|
||||
reject_favourite: お気に入りを拒否
|
||||
reject_media: メディアを拒否する
|
||||
reject_reply: リプライを拒否
|
||||
reject_reports: 通報を拒否
|
||||
silence: 制限
|
||||
suspend: サスペンド
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AddRejectFavouriteToDomainBlocks < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :domain_blocks, :reject_favourite, :boolean, null: false, default: false
|
||||
add_column :domain_blocks, :reject_reply, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2023_04_26_013738) do
|
||||
ActiveRecord::Schema.define(version: 2023_04_27_022606) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -468,6 +468,8 @@ ActiveRecord::Schema.define(version: 2023_04_26_013738) do
|
|||
t.text "private_comment"
|
||||
t.text "public_comment"
|
||||
t.boolean "obfuscate", default: false, null: false
|
||||
t.boolean "reject_favourite", default: false, null: false
|
||||
t.boolean "reject_reply", default: false, null: false
|
||||
t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue