Merge branch 'master' into add/extendable-transformers
This commit is contained in:
commit
3a5b530111
3 changed files with 15 additions and 2 deletions
|
@ -41,9 +41,14 @@ class Webfinger {
|
||||||
* @return string|WP_Error The URL or WP_Error
|
* @return string|WP_Error The URL or WP_Error
|
||||||
*/
|
*/
|
||||||
public static function resolve( $resource ) {
|
public static function resolve( $resource ) {
|
||||||
|
if ( ! $resource ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! preg_match( '/^@?' . ACTIVITYPUB_USERNAME_REGEXP . '$/i', $resource, $m ) ) {
|
if ( ! preg_match( '/^@?' . ACTIVITYPUB_USERNAME_REGEXP . '$/i', $resource, $m ) ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$transient_key = 'activitypub_resolve_' . ltrim( $resource, '@' );
|
$transient_key = 'activitypub_resolve_' . ltrim( $resource, '@' );
|
||||||
|
|
||||||
$link = \get_transient( $transient_key );
|
$link = \get_transient( $transient_key );
|
||||||
|
|
|
@ -236,8 +236,12 @@ class Inbox {
|
||||||
$params['actor'] = array(
|
$params['actor'] = array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'sanitize_callback' => function( $param, $request, $key ) {
|
'sanitize_callback' => function( $param, $request, $key ) {
|
||||||
if ( ! \is_string( $param ) ) {
|
if ( \is_array( $param ) ) {
|
||||||
$param = $param['id'];
|
if ( isset( $param['id'] ) ) {
|
||||||
|
$param = $param['id'];
|
||||||
|
} else {
|
||||||
|
$param = $param['url'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return \esc_url_raw( $param );
|
return \esc_url_raw( $param );
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,6 +30,10 @@ class Webfinger {
|
||||||
public static function add_user_discovery( $array, $resource, $user ) {
|
public static function add_user_discovery( $array, $resource, $user ) {
|
||||||
$user = User_Collection::get_by_id( $user->ID );
|
$user = User_Collection::get_by_id( $user->ID );
|
||||||
|
|
||||||
|
if ( ! $user || is_wp_error( $user ) ) {
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
|
||||||
$array['links'][] = array(
|
$array['links'][] = array(
|
||||||
'rel' => 'self',
|
'rel' => 'self',
|
||||||
'type' => 'application/activity+json',
|
'type' => 'application/activity+json',
|
||||||
|
|
Loading…
Reference in a new issue