check if ID is set

fallback to URL
This commit is contained in:
Matthias Pfefferle 2023-11-21 15:05:12 +01:00
parent d00e5a03c8
commit 1af821621b

View file

@ -123,6 +123,7 @@ class Inbox {
* @return WP_REST_Response * @return WP_REST_Response
*/ */
public static function user_inbox_post( $request ) { public static function user_inbox_post( $request ) {
var_dump( $request->get_params() );
$user_id = $request->get_param( 'user_id' ); $user_id = $request->get_param( 'user_id' );
$user = User_Collection::get_by_various( $user_id ); $user = User_Collection::get_by_various( $user_id );
@ -236,8 +237,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 );
}, },