updated plugin ActivityPub
version 3.3.3
This commit is contained in:
wp-content/plugins/activitypub
activitypub.php
assets
build
editor-plugin
follow-me
followers
remote-reply
reply-intent
reply
includes
activity
class-activity-dispatcher.phpclass-activitypub.phpclass-admin.phpclass-blocks.phpclass-cli.phpclass-comment.phpclass-debug.phpclass-handler.phpclass-hashtag.phpclass-health-check.phpclass-http.phpclass-link.phpclass-mention.phpclass-migration.phpclass-notification.phpclass-scheduler.phpclass-shortcodes.phpclass-signature.phpclass-webfinger.phpcollection
compat.phpdebug.phpfunctions.phphandler
class-announce.phpclass-create.phpclass-delete.phpclass-follow.phpclass-like.phpclass-undo.phpclass-update.php
help.phpmodel
rest
class-actors.phpclass-collection.phpclass-comment.phpclass-followers.phpclass-following.phpclass-inbox.phpclass-interaction.phpclass-nodeinfo.phpclass-outbox.phpclass-server.phpclass-webfinger.php
table
transformer
integration
class-buddypress.phpclass-enable-mastodon-apps.phpclass-jetpack.phpclass-nodeinfo.phpclass-opengraph.phpclass-seriously-simple-podcasting.phpclass-stream-connector.phpclass-webfinger.phpload.php
readme.txttemplates
@ -1,12 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* WebFinger REST-Class file.
|
||||
*
|
||||
* @package Activitypub
|
||||
*/
|
||||
|
||||
namespace Activitypub\Rest;
|
||||
|
||||
use WP_Error;
|
||||
use WP_REST_Response;
|
||||
use Activitypub\Collection\Users as User_Collection;
|
||||
|
||||
/**
|
||||
* ActivityPub WebFinger REST-Class
|
||||
* ActivityPub WebFinger REST-Class.
|
||||
*
|
||||
* @author Matthias Pfefferle
|
||||
*
|
||||
@ -15,8 +19,6 @@ use Activitypub\Collection\Users as User_Collection;
|
||||
class Webfinger {
|
||||
/**
|
||||
* Initialize the class, registering WordPress hooks.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function init() {
|
||||
self::register_routes();
|
||||
@ -24,8 +26,6 @@ class Webfinger {
|
||||
|
||||
/**
|
||||
* Register routes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register_routes() {
|
||||
\register_rest_route(
|
||||
@ -45,13 +45,13 @@ class Webfinger {
|
||||
/**
|
||||
* WebFinger endpoint.
|
||||
*
|
||||
* @param WP_REST_Request $request The request object.
|
||||
* @param \WP_REST_Request $request The request object.
|
||||
*
|
||||
* @return WP_REST_Response The response object.
|
||||
*/
|
||||
public static function webfinger( $request ) {
|
||||
/*
|
||||
* Action triggerd prior to the ActivityPub profile being created and sent to the client
|
||||
/**
|
||||
* Action triggered prior to the ActivityPub profile being created and sent to the client.
|
||||
*/
|
||||
\do_action( 'activitypub_rest_webfinger_pre' );
|
||||
|
||||
@ -74,13 +74,13 @@ class Webfinger {
|
||||
$code,
|
||||
array(
|
||||
'Access-Control-Allow-Origin' => '*',
|
||||
'Content-Type' => 'application/jrd+json; charset=' . get_option( 'blog_charset' ),
|
||||
'Content-Type' => 'application/jrd+json; charset=' . get_option( 'blog_charset' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The supported parameters
|
||||
* The supported parameters.
|
||||
*
|
||||
* @return array list of parameters
|
||||
*/
|
||||
@ -89,8 +89,8 @@ class Webfinger {
|
||||
|
||||
$params['resource'] = array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'pattern' => '^(acct:)|^(https?://)(.+)$',
|
||||
'type' => 'string',
|
||||
'pattern' => '^(acct:)|^(https?://)(.+)$',
|
||||
);
|
||||
|
||||
return $params;
|
||||
@ -99,47 +99,17 @@ class Webfinger {
|
||||
/**
|
||||
* Get the WebFinger profile.
|
||||
*
|
||||
* @param string $resource the WebFinger resource.
|
||||
* @param string $webfinger the WebFinger resource.
|
||||
*
|
||||
* @return array the WebFinger profile.
|
||||
* @return array|\WP_Error The WebFinger profile or WP_Error if not found.
|
||||
*/
|
||||
public static function get_profile( $resource ) {
|
||||
$user = User_Collection::get_by_resource( $resource );
|
||||
|
||||
if ( \is_wp_error( $user ) ) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
$aliases = array(
|
||||
$user->get_url(),
|
||||
$user->get_alternate_url(),
|
||||
);
|
||||
|
||||
$aliases = array_unique( $aliases );
|
||||
|
||||
$profile = array(
|
||||
'subject' => sprintf( 'acct:%s', $user->get_webfinger() ),
|
||||
'aliases' => array_values( array_unique( $aliases ) ),
|
||||
'links' => array(
|
||||
array(
|
||||
'rel' => 'self',
|
||||
'type' => 'application/activity+json',
|
||||
'href' => $user->get_url(),
|
||||
),
|
||||
array(
|
||||
'rel' => 'http://webfinger.net/rel/profile-page',
|
||||
'type' => 'text/html',
|
||||
'href' => $user->get_url(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if ( 'Person' !== $user->get_type() ) {
|
||||
$profile['links'][0]['properties'] = array(
|
||||
'https://www.w3.org/ns/activitystreams#type' => $user->get_type(),
|
||||
);
|
||||
}
|
||||
|
||||
return $profile;
|
||||
public static function get_profile( $webfinger ) {
|
||||
/**
|
||||
* Filter the WebFinger data.
|
||||
*
|
||||
* @param array $data The WebFinger data.
|
||||
* @param string $webfinger The WebFinger resource.
|
||||
*/
|
||||
return apply_filters( 'webfinger_data', array(), $webfinger );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user