PluginProbe
ActivityPub / 5.7.0
ActivityPub v5.7.0
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 | includes/model/class-user.php +42 -54 8.2.15.7.0 View file →
@@ -7,14 +7,15 @@
7 7
8 8 namespace Activitypub\Model;
9 9
10 10 use Activitypub\Activity\Actor;
11 -use Activitypub\Collection\Actors;
12 11 use Activitypub\Collection\Extra_Fields;
12 +use Activitypub\Http;
13 +use Activitypub\Signature;
13 14
15 +use function Activitypub\is_blog_public;
16 +use function Activitypub\get_rest_url_by_path;
14 17 use function Activitypub\get_attribution_domains;
15 -use function Activitypub\get_rest_url_by_path;
16 -use function Activitypub\is_blog_public;
17 18 use function Activitypub\user_can_activitypub;
18 19
19 20 /**
20 21 * User class.
@@ -29,8 +30,22 @@
29 30 */
30 31 protected $_id; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
31 32
32 33 /**
34 + * The Featured-Posts.
35 + *
36 + * @see https://docs.joinmastodon.org/spec/activitypub/#featured
37 + *
38 + * @context {
39 + * "@id": "http://joinmastodon.org/ns#featured",
40 + * "@type": "@id"
41 + * }
42 + *
43 + * @var string
44 + */
45 + protected $featured;
46 +
47 + /**
33 48 * Whether the User is discoverable.
34 49 *
35 50 * @see https://docs.joinmastodon.org/spec/activitypub/#discoverable
36 51 *
@@ -40,26 +55,24 @@
40 55 */
41 56 protected $discoverable = true;
42 57
43 58 /**
44 - * The generator of the object.
59 + * Whether the User is indexable.
45 60 *
46 - * @see https://www.w3.org/TR/activitypub/#generator
47 - * @see https://codeberg.org/fediverse/fep/src/branch/main/fep/844e/fep-844e.md#discovery-through-an-actor
61 + * @context http://joinmastodon.org/ns#indexable
48 62 *
49 - * @var array
63 + * @var boolean
50 64 */
51 - protected $generator = array(
52 - 'type' => 'Application',
53 - 'implements' => array(
54 - array(
55 - 'href' => 'https://datatracker.ietf.org/doc/html/rfc9421',
56 - 'name' => 'RFC-9421: HTTP Message Signatures',
57 - ),
58 - ),
59 - );
65 + protected $indexable;
60 66
61 67 /**
68 + * The WebFinger Resource.
69 + *
70 + * @var string
71 + */
72 + protected $webfinger;
73 +
74 + /**
62 75 * Constructor.
63 76 *
64 77 * @param int $user_id Optional. The WordPress user ID. Default null.
65 78 */
@@ -121,9 +134,9 @@
121 134 if ( '1' === $permalink ) {
122 135 return $this->get_url();
123 136 }
124 137
125 - return \add_query_arg( 'author', $this->_id, \home_url( '/' ) );
138 + return \add_query_arg( 'author', $this->_id, \trailingslashit( \home_url() ) );
126 139 }
127 140
128 141 /**
129 142 * Get the Username.
@@ -170,16 +183,9 @@
170 183 *
171 184 * @return string The preferred username.
172 185 */
173 186 public function get_preferred_username() {
174 - $login = \get_the_author_meta( 'login', $this->_id );
175 -
176 - // Handle cases where login is an email address (e.g., from Site Kit Google login).
177 - if ( \filter_var( $login, FILTER_VALIDATE_EMAIL ) ) {
178 - $login = \get_the_author_meta( 'user_nicename', $this->_id );
179 - }
180 -
181 - return $login;
187 + return \get_the_author_meta( 'login', $this->_id );
182 188 }
183 189
184 190 /**
185 191 * Get the User icon.
@@ -252,9 +258,9 @@
252 258 public function get_public_key() {
253 259 return array(
254 260 'id' => $this->get_id() . '#main-key',
255 261 'owner' => $this->get_id(),
256 - 'publicKeyPem' => Actors::get_public_key( $this->get__id() ),
262 + 'publicKeyPem' => Signature::get_public_key_for( $this->get__id() ),
257 263 );
258 264 }
259 265
260 266 /**
@@ -293,19 +299,8 @@
293 299 return get_rest_url_by_path( sprintf( 'actors/%d/following', $this->get__id() ) );
294 300 }
295 301
296 302 /**
297 - * Returns the Liked API endpoint.
298 - *
299 - * @since 8.1.0
300 - *
301 - * @return string The Liked endpoint.
302 - */
303 - public function get_liked() {
304 - return get_rest_url_by_path( sprintf( 'actors/%d/liked', $this->get__id() ) );
305 - }
306 -
307 - /**
308 303 * Returns the Featured-API-Endpoint.
309 304 *
310 305 * @return string The Featured-Endpoint.
311 306 */
@@ -313,30 +308,22 @@
313 308 return get_rest_url_by_path( sprintf( 'actors/%d/collections/featured', $this->get__id() ) );
314 309 }
315 310
316 311 /**
317 - * Returns the Featured-Tags-API-Endpoint.
318 - *
319 - * @return string The Featured-Tags-Endpoint.
320 - */
321 - public function get_featured_tags() {
322 - return get_rest_url_by_path( sprintf( 'actors/%d/collections/tags', $this->get__id() ) );
323 - }
324 -
325 - /**
326 312 * Returns the endpoints.
327 313 *
328 314 * @return string[]|null The endpoints.
329 315 */
330 316 public function get_endpoints() {
331 - return array(
332 - 'sharedInbox' => get_rest_url_by_path( 'inbox' ),
333 - 'oauthAuthorizationEndpoint' => get_rest_url_by_path( 'oauth/authorize' ),
334 - 'oauthTokenEndpoint' => get_rest_url_by_path( 'oauth/token' ),
335 - 'oauthRegistrationEndpoint' => get_rest_url_by_path( 'oauth/clients' ),
336 - 'proxyUrl' => get_rest_url_by_path( 'proxy' ),
337 - 'proxyEventStream' => get_rest_url_by_path( 'proxy/stream' ),
338 - );
317 + $endpoints = null;
318 +
319 + if ( \get_option( 'activitypub_shared_inbox' ) ) {
320 + $endpoints = array(
321 + 'sharedInbox' => get_rest_url_by_path( 'inbox' ),
322 + );
323 + }
324 +
325 + return $endpoints;
339 326 }
340 327
341 328 /**
342 329 * Extend the User-Output with Attachments.
@@ -467,8 +454,9 @@
467 454 $this->get_url(),
468 455 $this->get_alternate_url(),
469 456 );
470 457
458 + // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
471 459 $also_known_as = array_merge( $also_known_as, \get_user_option( 'activitypub_also_known_as', $this->_id ) ?: array() );
472 460
473 461 return array_unique( $also_known_as );
474 462 }