PluginProbe
ActivityPub / 7.7.0
ActivityPub v7.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/rest/class-application-controller.php +2 -105 9.3.07.7.0 View file →
@@ -1,26 +1,15 @@
1 1 <?php
2 2 /**
3 3 * Application Controller file.
4 4 *
5 - * Self-contained controller for the ActivityPub Application actor.
6 - * The Application is not a real actor in the plugin's internal sense —
7 - * it cannot be followed, addressed, or interacted with. It exists only as:
8 - * 1. A JSON-LD document at /wp-json/activitypub/1.0/application
9 - * 2. A signing identity for outbound HTTP GET requests
10 - *
11 5 * @package Activitypub
12 6 */
13 7
14 8 namespace Activitypub\Rest;
15 9
16 -use Activitypub\Activity\Actor;
17 -use Activitypub\Activity\Generic_Object;
18 -use Activitypub\Application;
10 +use Activitypub\Model\Application;
19 11
20 -use function Activitypub\get_rest_url_by_path;
21 -use function Activitypub\home_host;
22 -
23 12 /**
24 13 * ActivityPub Application Controller.
25 14 */
26 15 class Application_Controller extends \WP_REST_Controller {
@@ -53,82 +42,19 @@
53 42 ),
54 43 'schema' => array( $this, 'get_item_schema' ),
55 44 )
56 45 );
57 -
58 - \register_rest_route(
59 - $this->namespace,
60 - '/' . $this->rest_base . '/outbox',
61 - array(
62 - array(
63 - 'methods' => \WP_REST_Server::READABLE,
64 - 'callback' => array( $this, 'get_outbox' ),
65 - 'permission_callback' => '__return_true',
66 - ),
67 - )
68 - );
69 46 }
70 47
71 48 /**
72 49 * Retrieves the application actor profile.
73 50 *
74 - * @since 9.1.0
75 - *
76 51 * @param \WP_REST_Request $request The request object.
77 52 * @return \WP_REST_Response Response object.
78 53 */
79 54 public function get_item( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
80 - $id = Application::get_id();
55 + $json = ( new Application() )->to_array();
81 56
82 - $json = array(
83 - '@context' => Actor::JSON_LD_CONTEXT,
84 - 'id' => $id,
85 - 'type' => 'Application',
86 - 'name' => Application::USERNAME,
87 - 'preferredUsername' => Application::USERNAME,
88 - 'summary' => sprintf(
89 - /* translators: %s: Domain of the site */
90 - \__( 'This is the Application Actor for %s.', 'activitypub' ),
91 - home_host()
92 - ),
93 - 'url' => Application::get_url(),
94 - 'icon' => Application::get_icon(),
95 - 'published' => Application::get_published(),
96 - 'inbox' => get_rest_url_by_path( 'inbox' ),
97 - 'outbox' => get_rest_url_by_path( 'application/outbox' ),
98 - 'manuallyApprovesFollowers' => true,
99 - 'discoverable' => false,
100 - 'indexable' => false,
101 - 'invisible' => true,
102 - 'webfinger' => Application::get_webfinger(),
103 - 'publicKey' => array(
104 - 'id' => Application::get_key_id(),
105 - 'owner' => $id,
106 - 'publicKeyPem' => Application::get_public_key(),
107 - ),
108 - 'implements' => array(
109 - array(
110 - 'href' => 'https://datatracker.ietf.org/doc/html/rfc9421',
111 - 'name' => 'RFC-9421: HTTP Message Signatures',
112 - ),
113 - ),
114 - );
115 -
116 - /*
117 - * Run the same serialization filters the object-based path used, so
118 - * integrations that add actor fields via these hooks still apply to the
119 - * Application actor. The filters document a Generic_Object argument, so
120 - * hydrate one from the array to keep that contract.
121 - */
122 - $class = 'application';
123 - $object = Generic_Object::init_from_array( $json );
124 -
125 - /** This filter is documented in includes/activity/class-generic-object.php */
126 - $json = \apply_filters( 'activitypub_activity_object_array', $json, $class, $id, $object );
127 -
128 - /** This filter is documented in includes/activity/class-generic-object.php */
129 - $json = \apply_filters( "activitypub_activity_{$class}_object_array", $json, $id, $object );
130 -
131 57 $rest_response = new \WP_REST_Response( $json, 200 );
132 58 $rest_response->header( 'Content-Type', 'application/activity+json; charset=' . \get_option( 'blog_charset' ) );
133 59
134 60 return $rest_response;
@@ -134,34 +60,8 @@
134 60 return $rest_response;
135 61 }
136 62
137 63 /**
138 - * Returns an empty outbox collection for the Application actor.
139 - *
140 - * The Application is a signing-only identity and does not publish
141 - * activities, so its outbox is always an empty OrderedCollection.
142 - *
143 - * @since 9.1.0
144 - *
145 - * @param \WP_REST_Request $request The request object.
146 - * @return \WP_REST_Response Response object.
147 - */
148 - public function get_outbox( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
149 - $json = array(
150 - '@context' => Actor::JSON_LD_CONTEXT,
151 - 'id' => get_rest_url_by_path( 'application/outbox' ),
152 - 'type' => 'OrderedCollection',
153 - 'totalItems' => 0,
154 - 'orderedItems' => array(),
155 - );
156 -
157 - $rest_response = new \WP_REST_Response( $json, 200 );
158 - $rest_response->header( 'Content-Type', 'application/activity+json; charset=' . \get_option( 'blog_charset' ) );
159 -
160 - return $rest_response;
161 - }
162 -
163 - /**
164 64 * Retrieves the schema for the application endpoint.
165 65 *
166 66 * @return array Schema data.
167 67 */
@@ -254,11 +154,8 @@
254 154 'discoverable' => array(
255 155 'type' => 'boolean',
256 156 ),
257 157 'indexable' => array(
258 - 'type' => 'boolean',
259 - ),
260 - 'invisible' => array(
261 158 'type' => 'boolean',
262 159 ),
263 160 'implements' => array(
264 161 'type' => 'array',