updated plugin ActivityPub version 3.3.3

This commit is contained in:
2024-10-09 12:44:17 +00:00
committed by Gitium
parent fb4b27bbc6
commit c54fa007bd
106 changed files with 7070 additions and 2918 deletions
wp-content/plugins/activitypub
activitypub.php
assets
build
includes
integration
readme.txt
templates

@ -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 );
}
}