PluginProbe
ActivityPub / 3.2.2
ActivityPub v3.2.2
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | integration/class-webfinger.php +45 -4 2.1.13.2.2 View file →
@@ -3,8 +3,10 @@
3 3
4 4 use Activitypub\Rest\Webfinger as Webfinger_Rest;
5 5 use Activitypub\Collection\Users as User_Collection;
6 6
7 +use function Activitypub\get_rest_url_by_path;
8 +
7 9 /**
8 10 * Compatibility with the WebFinger plugin
9 11 *
10 12 * @see https://wordpress.org/plugins/webfinger/
@@ -44,8 +46,13 @@
44 46 'type' => 'application/activity+json',
45 47 'href' => $user->get_url(),
46 48 );
47 49
50 + $array['links'][] = array(
51 + 'rel' => 'http://ostatus.org/schema/1.0/subscribe',
52 + 'template' => get_rest_url_by_path( 'interactions?uri={uri}' ),
53 + );
54 +
48 55 return $array;
49 56 }
50 57
51 58 /**
@@ -57,13 +64,47 @@
57 64 *
58 65 * @return array the jrd array
59 66 */
60 67 public static function add_pseudo_user_discovery( $array, $resource ) {
61 - $user = Webfinger_Rest::get_profile( $resource );
68 + $user = User_Collection::get_by_resource( $resource );
62 69
63 - if ( ! $user || is_wp_error( $user ) ) {
64 - return $array;
70 + if ( \is_wp_error( $user ) ) {
71 + return $user;
65 72 }
66 73
67 - return $user;
74 + $aliases = array(
75 + $user->get_url(),
76 + $user->get_alternate_url(),
77 + );
78 +
79 + $aliases = array_unique( $aliases );
80 +
81 + $profile = array(
82 + 'subject' => sprintf( 'acct:%s', $user->get_webfinger() ),
83 + 'aliases' => array_values( array_unique( $aliases ) ),
84 + 'links' => array(
85 + array(
86 + 'rel' => 'self',
87 + 'type' => 'application/activity+json',
88 + 'href' => $user->get_url(),
89 + ),
90 + array(
91 + 'rel' => 'http://webfinger.net/rel/profile-page',
92 + 'type' => 'text/html',
93 + 'href' => $user->get_url(),
94 + ),
95 + array(
96 + 'rel' => 'http://ostatus.org/schema/1.0/subscribe',
97 + 'template' => get_rest_url_by_path( 'interactions?uri={uri}' ),
98 + ),
99 + ),
100 + );
101 +
102 + if ( 'Person' !== $user->get_type() ) {
103 + $profile['links'][0]['properties'] = array(
104 + 'https://www.w3.org/ns/activitystreams#type' => $user->get_type(),
105 + );
106 + }
107 +
108 + return $profile;
68 109 }
69 110 }