Fix the health check (#481)
* only test author urls if authors are enabled * if authors are disabled use the blog user to test webfinger
This commit is contained in:
parent
336f3e5a62
commit
b7c0e011de
1 changed files with 17 additions and 6 deletions
|
@ -3,8 +3,10 @@ namespace Activitypub;
|
||||||
|
|
||||||
use WP_Error;
|
use WP_Error;
|
||||||
use Activitypub\Webfinger;
|
use Activitypub\Webfinger;
|
||||||
|
use Activitypub\Collection\Users;
|
||||||
|
|
||||||
use function Activitypub\get_plugin_version;
|
use function Activitypub\get_plugin_version;
|
||||||
|
use function Activitypub\is_user_type_disabled;
|
||||||
use function Activitypub\get_webfinger_resource;
|
use function Activitypub\get_webfinger_resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,10 +27,12 @@ class Health_Check {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function add_tests( $tests ) {
|
public static function add_tests( $tests ) {
|
||||||
$tests['direct']['activitypub_test_author_url'] = array(
|
if ( ! is_user_type_disabled( 'user' ) ) {
|
||||||
'label' => \__( 'Author URL test', 'activitypub' ),
|
$tests['direct']['activitypub_test_author_url'] = array(
|
||||||
'test' => array( self::class, 'test_author_url' ),
|
'label' => \__( 'Author URL test', 'activitypub' ),
|
||||||
);
|
'test' => array( self::class, 'test_author_url' ),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$tests['direct']['activitypub_test_webfinger'] = array(
|
$tests['direct']['activitypub_test_webfinger'] = array(
|
||||||
'label' => __( 'WebFinger Test', 'activitypub' ),
|
'label' => __( 'WebFinger Test', 'activitypub' ),
|
||||||
|
@ -253,8 +257,15 @@ class Health_Check {
|
||||||
* @return boolean|WP_Error
|
* @return boolean|WP_Error
|
||||||
*/
|
*/
|
||||||
public static function is_webfinger_endpoint_accessible() {
|
public static function is_webfinger_endpoint_accessible() {
|
||||||
$user = \wp_get_current_user();
|
$user = \wp_get_current_user();
|
||||||
$account = get_webfinger_resource( $user->ID );
|
|
||||||
|
if ( ! is_user_type_disabled( 'blog' ) ) {
|
||||||
|
$account = get_webfinger_resource( $user->ID );
|
||||||
|
} elseif ( ! is_user_type_disabled( 'user' ) ) {
|
||||||
|
$account = get_webfinger_resource( Users::BLOG_USER_ID );
|
||||||
|
} else {
|
||||||
|
$account = '';
|
||||||
|
}
|
||||||
|
|
||||||
$url = Webfinger::resolve( $account );
|
$url = Webfinger::resolve( $account );
|
||||||
if ( \is_wp_error( $url ) ) {
|
if ( \is_wp_error( $url ) ) {
|
||||||
|
|
Loading…
Reference in a new issue