From 75bf26db6ae576c888ef2c7cd9af7e7c23ce2e51 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Mon, 29 Jul 2024 22:55:01 +0200 Subject: [PATCH] Fix the friends_cache_url_post_id filter --- feed-parsers/class-feed-parser-activitypub.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/feed-parsers/class-feed-parser-activitypub.php b/feed-parsers/class-feed-parser-activitypub.php index 3d3306a6..8d4f66b3 100644 --- a/feed-parsers/class-feed-parser-activitypub.php +++ b/feed-parsers/class-feed-parser-activitypub.php @@ -104,7 +104,7 @@ public function __construct( Feed $friends_feed ) { add_filter( 'mastodon_api_status', array( $this, 'mastodon_api_status_add_reblogs' ), 40, 3 ); add_filter( 'mastodon_api_canonical_user_id', array( $this, 'mastodon_api_canonical_user_id' ), 20, 3 ); add_filter( 'mastodon_api_comment_parent_post_id', array( $this, 'mastodon_api_comment_parent_post_id' ), 25 ); - add_filter( 'friends_cache_url_post_id', array( '\Friends\Feed', 'url_to_postid' ) ); + add_filter( 'friends_cache_url_post_id', array( $this, 'check_url_to_postid' ), 10, 2 ); add_action( 'friends_comments_form', array( self::class, 'comment_form' ) ); } @@ -1492,7 +1492,6 @@ public function cache_url( $url ) { $user_feed = $this->get_external_mentions_feed(); $response = \Activitypub\safe_remote_get( $url, get_current_user_id() ); if ( \is_wp_error( $response ) ) { - $this->show_message_on_frontend( sprintf( // translators: %s is a URl. @@ -1523,6 +1522,13 @@ public function cache_url( $url ) { return $post_id; } + public function check_url_to_postid( $post_id, $url ) { + if ( ! $post_id ) { + $post_id = \Friends\Feed::url_to_postid( $url ); + } + return $post_id; + } + public function the_content( $the_content ) { $protected_tags = array(); $the_content = preg_replace_callback(