Skip to content

Commit

Permalink
Fix the friends_cache_url_post_id filter
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk committed Jul 29, 2024
1 parent 284049a commit 75bf26d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions feed-parsers/class-feed-parser-activitypub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 75bf26d

Please sign in to comment.