From a875b900541b9acba250f08fd7a7961754da3fae Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Mon, 21 Sep 2020 13:20:39 +0200 Subject: [PATCH] remove blocklist feature in favor of the comment blocklist --- includes/class-admin.php | 8 ------- includes/functions.php | 45 ----------------------------------- includes/rest/class-inbox.php | 24 ------------------- templates/settings.php | 10 ++------ 4 files changed, 2 insertions(+), 85 deletions(-) diff --git a/includes/class-admin.php b/includes/class-admin.php index d7cbfdd..6eb2fa8 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -107,14 +107,6 @@ class Admin { 'default' => array( 'post', 'pages' ), ) ); - \register_setting( - 'activitypub', 'activitypub_blacklist', array( - 'type' => 'string', - 'description' => \esc_html__( 'Block fediverse instances', 'activitypub' ), - 'show_in_rest' => true, - 'default' => 'gab.com', - ) - ); } public static function add_settings_help_tab() { diff --git a/includes/functions.php b/includes/functions.php index 90dec8a..43cc40e 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -287,48 +287,3 @@ function url_to_authorid( $url ) { return 0; } - -/** - * Get the blacklist from the WordPress options table - * - * @return array the list of blacklisted hosts - * - * @uses apply_filters() Calls 'activitypub_blacklist' filter - */ -function get_blacklist() { - $blacklist = \get_option( 'activitypub_blacklist', 'gab.com' ); - $blacklist_hosts = \explode( \PHP_EOL, $blacklist ); - - // if no values have been set, revert to the defaults - if ( ! $blacklist || ! $blacklist_hosts || ! \is_array( $blacklist_hosts ) ) { - $blacklist_hosts = array(); - } - - // clean out any blank values - foreach ( $blacklist_hosts as $key => $value ) { - if ( empty( $value ) ) { - unset( $blacklist_hosts[ $key ] ); - } else { - $blacklist_hosts[ $key ] = \trim( $blacklist_hosts[ $key ] ); - } - } - - return \apply_filters( 'activitypub_blacklist', $blacklist_hosts ); -} - -/** - * Check if an URL is blacklisted - * - * @param string $url an URL to check - * - * @return boolean - */ -function is_blacklisted( $url ) { - foreach ( \ActivityPub\get_blacklist() as $blacklisted_host ) { - if ( \stripos( $url, $blacklisted_host ) !== false ) { - return true; - } - } - - return false; -} diff --git a/includes/rest/class-inbox.php b/includes/rest/class-inbox.php index 1834dab..088f8ad 100644 --- a/includes/rest/class-inbox.php +++ b/includes/rest/class-inbox.php @@ -135,23 +135,11 @@ class Inbox { $params['id'] = array( 'required' => true, - 'validate_callback' => function( $param, $request, $key ) { - if ( ! \is_string( $param ) ) { - $param = $param['id']; - } - return ! \Activitypub\is_blacklisted( $param ); - }, 'sanitize_callback' => 'esc_url_raw', ); $params['actor'] = array( 'required' => true, - 'validate_callback' => function( $param, $request, $key ) { - if ( ! \is_string( $param ) ) { - $param = $param['id']; - } - return ! \Activitypub\is_blacklisted( $param ); - }, 'sanitize_callback' => function( $param, $request, $key ) { if ( ! \is_string( $param ) ) { $param = $param['id']; @@ -188,24 +176,12 @@ class Inbox { $params['id'] = array( 'required' => true, 'type' => 'string', - 'validate_callback' => function( $param, $request, $key ) { - if ( ! \is_string( $param ) ) { - $param = $param['id']; - } - return ! \Activitypub\is_blacklisted( $param ); - }, 'sanitize_callback' => 'esc_url_raw', ); $params['actor'] = array( 'required' => true, //'type' => array( 'object', 'string' ), - 'validate_callback' => function( $param, $request, $key ) { - if ( ! \is_string( $param ) ) { - $param = $param['id']; - } - return ! \Activitypub\is_blacklisted( $param ); - }, 'sanitize_callback' => function( $param, $request, $key ) { if ( ! \is_string( $param ) ) { $param = $param['id']; diff --git a/templates/settings.php b/templates/settings.php index 76f4452..5a4ba9d 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -108,20 +108,14 @@

- -
- + - -

http:// and without www.. For example example.com.', 'activitypub' ); ?>

+

Disallowed Comment Keys" list.', 'activitypub' ), admin_url( 'options-discussion.php#disallowed_keys' ) ); ?>