Fix author name override for announced posts

This commit is contained in:
Alex Kirk 2022-12-02 13:59:00 +01:00
parent b3a26788eb
commit db9e69f6e8
2 changed files with 4 additions and 2 deletions

View file

@ -231,9 +231,9 @@ class Friends_Feed_Parser_ActivityPub extends \Friends\Feed_Parser {
$meta = \Activitypub\get_remote_metadata_by_actor( $object['attributedTo'] );
$this->log( 'Attributed to ' . $object['attributedTo'], compact( 'meta' ) );
if ( isset( $meta['name'] ) ) {
$override_author = $meta['name'];
$data['author'] = $meta['name'];
} elseif ( isset( $meta['preferredUsername'] ) ) {
$override_author = $meta['preferredUsername'];
$data['author'] = $meta['preferredUsername'];
}
}

View file

@ -253,6 +253,7 @@ class Test_Friends_Feed_Parser_ActivityPub extends \WP_UnitTestCase {
$this->assertEquals( $post_count + 2, count( $posts ) );
$this->assertEquals( $content, $posts[0]->post_content );
$this->assertEquals( $this->friend_id, $posts[0]->post_author );
$this->assertEquals( $this->friend_name, get_post_meta( $posts[0]->ID, 'author', true ) );
}
public function test_incoming_announce() {
@ -304,6 +305,7 @@ class Test_Friends_Feed_Parser_ActivityPub extends \WP_UnitTestCase {
$this->assertEquals( $post_count + 1, count( $posts ) );
$this->assertStringContainsString( 'Dezentrale Netzwerke', $posts[0]->post_content );
$this->assertEquals( $this->friend_id, $posts[0]->post_author );
$this->assertEquals( 'Matthias Pfefferle', get_post_meta( $posts[0]->ID, 'author', true ) );
}
}