parent
96da1fcb00
commit
8793bc286e
13 changed files with 71 additions and 10 deletions
|
@ -89,17 +89,18 @@ module Admin
|
|||
|
||||
def update_params
|
||||
params.require(:domain_block).permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag,
|
||||
:reject_straight_follow, :reject_new_follow, :reject_friend, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden)
|
||||
:reject_straight_follow, :reject_new_follow, :reject_friend, :block_trends, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden)
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag,
|
||||
:reject_straight_follow, :reject_new_follow, :reject_friend, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden)
|
||||
:reject_straight_follow, :reject_new_follow, :reject_friend, :block_trends, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden)
|
||||
end
|
||||
|
||||
def form_domain_block_batch_params
|
||||
params.require(:form_domain_block_batch).permit(domain_blocks_attributes: [:enabled, :domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers,
|
||||
:reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :reject_friend, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden])
|
||||
:reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :reject_friend, :block_trends, :detect_invalid_subscription,
|
||||
:reject_reports, :private_comment, :public_comment, :obfuscate, :hidden])
|
||||
end
|
||||
|
||||
def action_from_button
|
||||
|
|
|
@ -70,7 +70,7 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
|
|||
|
||||
def domain_block_params
|
||||
params.permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_reports, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow,
|
||||
:reject_new_follow, :reject_friend, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden)
|
||||
:reject_new_follow, :reject_friend, :block_trends, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden)
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
|
@ -103,6 +103,6 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
|
|||
|
||||
def resource_params
|
||||
params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow,
|
||||
:reject_new_follow, :reject_friend, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden)
|
||||
:reject_new_follow, :reject_friend, :block_trends, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
# detect_invalid_subscription :boolean default(FALSE), not null
|
||||
# reject_reply_exclude_followers :boolean default(FALSE), not null
|
||||
# reject_friend :boolean default(FALSE), not null
|
||||
# block_trends :boolean default(FALSE), not null
|
||||
#
|
||||
|
||||
class DomainBlock < ApplicationRecord
|
||||
|
@ -49,6 +50,7 @@ class DomainBlock < ApplicationRecord
|
|||
.or(where(reject_new_follow: true))
|
||||
.or(where(reject_straight_follow: true))
|
||||
.or(where(reject_friend: true))
|
||||
.or(where(block_trends: true))
|
||||
}
|
||||
scope :by_severity, -> { in_order_of(:severity, %w(noop silence suspend)).order(:domain) }
|
||||
|
||||
|
@ -70,6 +72,7 @@ class DomainBlock < ApplicationRecord
|
|||
reject_straight_follow? ? :reject_straight_follow : nil,
|
||||
reject_new_follow? ? :reject_new_follow : nil,
|
||||
reject_friend? ? :reject_friend : nil,
|
||||
block_trends? ? :block_trends : nil,
|
||||
detect_invalid_subscription? ? :detect_invalid_subscription : nil,
|
||||
reject_reports? ? :reject_reports : nil].reject { |policy| policy == :noop || policy.nil? }
|
||||
end
|
||||
|
@ -116,6 +119,10 @@ class DomainBlock < ApplicationRecord
|
|||
!!rule_for(domain)&.reject_friend?
|
||||
end
|
||||
|
||||
def block_trends?(domain)
|
||||
!!rule_for(domain)&.block_trends?
|
||||
end
|
||||
|
||||
def detect_invalid_subscription?(domain)
|
||||
!!rule_for(domain)&.detect_invalid_subscription?
|
||||
end
|
||||
|
|
|
@ -110,7 +110,13 @@ class Trends::Statuses < Trends::Base
|
|||
(status.public_visibility? || status.public_unlisted_visibility?) &&
|
||||
status.account.discoverable? && !status.account.silenced? && !status.account.sensitized? &&
|
||||
status.spoiler_text.blank? && (!status.sensitive? || status.media_attachments.none?) &&
|
||||
!status.reply? && valid_locale?(status.language)
|
||||
!status.reply? && valid_locale?(status.language) && !domain_blocked?(status)
|
||||
end
|
||||
|
||||
def domain_blocked?(status)
|
||||
return false if status.account.local?
|
||||
|
||||
DomainBlock.block_trends?(status.account.domain)
|
||||
end
|
||||
|
||||
def calculate_scores(statuses, at_time)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class REST::Admin::DomainBlockSerializer < ActiveModel::Serializer
|
||||
attributes :id, :domain, :created_at, :severity,
|
||||
:reject_media, :reject_favourite, :reject_reply, :reject_reports,
|
||||
:reject_reply_exclude_followers, :reject_send_sensitive,
|
||||
:reject_reply_exclude_followers, :reject_send_sensitive, :block_trends,
|
||||
:reject_hashtag, :reject_straight_follow, :reject_new_follow, :reject_friend, :detect_invalid_subscription,
|
||||
:private_comment, :public_comment, :obfuscate
|
||||
|
||||
|
|
|
@ -30,3 +30,6 @@
|
|||
|
||||
.fields-group
|
||||
= f.input :reject_send_sensitive, as: :boolean, kmyblue: true, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_sensitive'), hint: I18n.t('admin.domain_blocks.reject_send_sensitive_hint')
|
||||
|
||||
.fields-group
|
||||
= f.input :block_trends, as: :boolean, kmyblue: true, wrapper: :with_label, label: I18n.t('admin.domain_blocks.block_trends'), hint: I18n.t('admin.domain_blocks.block_trends_hint')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue