This commit is contained in:
Matthias Pfefferle 2023-08-10 15:35:10 +02:00
parent 1fd0cca185
commit 6e2656311b
2 changed files with 4 additions and 4 deletions

View file

@ -52,7 +52,7 @@ class Http {
$response = \wp_safe_remote_post( $url, $args ); $response = \wp_safe_remote_post( $url, $args );
$code = \wp_remote_retrieve_response_code( $response ); $code = \wp_remote_retrieve_response_code( $response );
if ( $code <= 400 ) { if ( $code >= 400 ) {
$response = new WP_Error( $code, __( 'Failed HTTP Request', 'activitypub' ) ); $response = new WP_Error( $code, __( 'Failed HTTP Request', 'activitypub' ) );
} }
@ -100,7 +100,7 @@ class Http {
$response = \wp_safe_remote_get( $url, $args ); $response = \wp_safe_remote_get( $url, $args );
$code = \wp_remote_retrieve_response_code( $response ); $code = \wp_remote_retrieve_response_code( $response );
if ( $code <= 400 ) { if ( $code >= 400 ) {
$response = new WP_Error( $code, __( 'Failed HTTP Request', 'activitypub' ) ); $response = new WP_Error( $code, __( 'Failed HTTP Request', 'activitypub' ) );
} }

View file

@ -59,8 +59,7 @@ class Mention {
); );
$the_content = \preg_replace_callback( '/@' . ACTIVITYPUB_USERNAME_REGEXP . '/', array( self::class, 'replace_with_links' ), $the_content ); $the_content = \preg_replace_callback( '/@' . ACTIVITYPUB_USERNAME_REGEXP . '/', array( self::class, 'replace_with_links' ), $the_content );
$the_content = \str_replace( array_reverse( array_keys( $protected_tags ) ), array_reverse( array_values( $protected_tags ) ), $the_content );
$the_content = str_replace( array_reverse( array_keys( $protected_tags ) ), array_reverse( array_values( $protected_tags ) ), $the_content );
return $the_content; return $the_content;
} }
@ -74,6 +73,7 @@ class Mention {
*/ */
public static function replace_with_links( $result ) { public static function replace_with_links( $result ) {
$metadata = get_remote_metadata_by_actor( $result[0] ); $metadata = get_remote_metadata_by_actor( $result[0] );
if ( ! is_wp_error( $metadata ) && ! empty( $metadata['url'] ) ) { if ( ! is_wp_error( $metadata ) && ! empty( $metadata['url'] ) ) {
$username = ltrim( $result[0], '@' ); $username = ltrim( $result[0], '@' );
if ( ! empty( $metadata['name'] ) ) { if ( ! empty( $metadata['name'] ) ) {