Suggest better display name and username

This commit is contained in:
Alex Kirk 2022-11-18 21:28:40 +01:00
parent 4cc9cda67a
commit 8320856e6a

View file

@ -54,11 +54,18 @@ class Friends_Feed_Parser_ActivityPub extends \Friends\Feed_Parser {
*/
public function update_feed_details( $feed_details ) {
$meta = \Activitypub\get_remote_metadata_by_actor( $feed_details['url'] );
if ( $meta && ! is_wp_error( $meta ) ) {
if ( isset( $meta['preferredUsername'] ) ) {
if ( ! $meta && is_wp_error( $meta ) ) {
return $meta;
}
if ( isset( $meta['name'] ) ) {
$feed_details['title'] = $meta['name'];
} elseif ( isset( $meta['preferredUsername'] ) ) {
$feed_details['title'] = $meta['preferredUsername'];
}
$feed_details['url'] = $meta['id'];
if ( isset( $meta['url'] ) ) {
$feed_details['url'] = $meta['url'];
}
return $feed_details;
@ -90,7 +97,7 @@ class Friends_Feed_Parser_ActivityPub extends \Friends\Feed_Parser {
$discovered_feeds[ $meta['id'] ] = array(
'type' => 'application/activity+json',
'rel' => 'self',
'post-format' => 'autodetect',
'post-format' => 'status',
'parser' => self::SLUG,
'autoselect' => true,
);