PluginProbe
ActivityPub / 9.2.0
ActivityPub v9.2.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
activitypub / includes / model / class-application.php

class-application.php in ActivityPub 9.2.0, at includes/model/class-application.php

237 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Application model file.
4 *
5 * @deprecated Use {@see \Activitypub\Application} for key management
6 * and {@see \Activitypub\Rest\Application_Controller} for the REST endpoint.
7 *
8 * @package Activitypub
9 */
10
11 namespace Activitypub\Model;
12
13 use Activitypub\Activity\Actor;
14 use Activitypub\Application as Application_Utility;
15
16 use function Activitypub\get_rest_url_by_path;
17 use function Activitypub\home_host;
18
19 /**
20 * Application class.
21 *
22 * @deprecated Use {@see \Activitypub\Application} instead.
23 */
24 class Application extends Actor {
25 /**
26 * The User-ID
27 *
28 * @var int
29 */
30 protected $_id = -1; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
31
32 /**
33 * Whether the Application is discoverable.
34 *
35 * @see https://docs.joinmastodon.org/spec/activitypub/#discoverable
36 *
37 * @context http://joinmastodon.org/ns#discoverable
38 *
39 * @var bool
40 */
41 protected $discoverable = false;
42
43 /**
44 * Whether the Application is indexable.
45 *
46 * @context http://joinmastodon.org/ns#indexable
47 *
48 * @var bool
49 */
50 protected $indexable = false;
51
52 /**
53 * Whether the Application manually approves followers.
54 *
55 * @see https://docs.joinmastodon.org/spec/activitypub/#as
56 *
57 * @context as:manuallyApprovesFollowers
58 *
59 * @var bool
60 */
61 protected $manually_approves_followers = true;
62
63 /**
64 * List of software capabilities implemented by the Application.
65 *
66 * @see https://codeberg.org/silverpill/feps/src/branch/main/844e/fep-844e.md
67 *
68 * @var array
69 */
70 protected $implements = array(
71 array(
72 'href' => 'https://datatracker.ietf.org/doc/html/rfc9421',
73 'name' => 'RFC-9421: HTTP Message Signatures',
74 ),
75 );
76
77 /**
78 * Set Application as invisible.
79 *
80 * @see https://litepub.social/
81 *
82 * @var bool
83 */
84 protected $invisible = true;
85
86 /**
87 * The type of the Actor.
88 *
89 * @var string
90 */
91 protected $type = 'Application';
92
93 /**
94 * The Username.
95 *
96 * @var string
97 */
98 protected $name = 'application';
99
100 /**
101 * The preferred username.
102 *
103 * @var string
104 */
105 protected $preferred_username = 'application';
106
107 /**
108 * Constructor.
109 */
110 public function __construct() {
111 \_deprecated_class( __CLASS__, '9.1.0', 'Activitypub\Application' );
112 }
113
114 /**
115 * Returns the ID of the Application.
116 *
117 * @return string The ID of the Application.
118 */
119 public function get_id() {
120 return Application_Utility::get_id();
121 }
122
123 /**
124 * Get the User-Url.
125 *
126 * @return string The User-Url.
127 */
128 public function get_url() {
129 return $this->get_id();
130 }
131
132 /**
133 * Returns the User-URL with @-Prefix for the username.
134 *
135 * @return string The User-URL with @-Prefix for the username.
136 */
137 public function get_alternate_url() {
138 return $this->get_id();
139 }
140
141 /**
142 * Get the User-Icon.
143 *
144 * @return string[] The User-Icon.
145 */
146 public function get_icon() {
147 return Application_Utility::get_icon();
148 }
149
150 /**
151 * Get the User-Header-Image.
152 *
153 * @return string[]|null The User-Header-Image.
154 */
155 public function get_header_image() {
156 if ( \has_header_image() ) {
157 return array(
158 'type' => 'Image',
159 'url' => \esc_url_raw( \get_header_image() ),
160 );
161 }
162
163 return null;
164 }
165
166 /**
167 * Get the first published date.
168 *
169 * @return string The published date.
170 */
171 public function get_published() {
172 return Application_Utility::get_published();
173 }
174
175 /**
176 * Returns the Inbox-API-Endpoint.
177 *
178 * @return string The Inbox-Endpoint.
179 */
180 public function get_inbox() {
181 return get_rest_url_by_path( 'inbox' );
182 }
183
184 /**
185 * Returns the Outbox-API-Endpoint.
186 *
187 * @return string The Outbox-Endpoint.
188 */
189 public function get_outbox() {
190 return get_rest_url_by_path( 'application/outbox' );
191 }
192
193 /**
194 * Returns a user@domain type of identifier for the user.
195 *
196 * @return string The Webfinger-Identifier.
197 */
198 public function get_webfinger() {
199 return $this->get_preferred_username() . '@' . \wp_parse_url( \home_url(), \PHP_URL_HOST );
200 }
201
202 /**
203 * Returns the public key.
204 *
205 * @return string[] The public key.
206 */
207 public function get_public_key() {
208 return array(
209 'id' => Application_Utility::get_key_id(),
210 'owner' => $this->get_id(),
211 'publicKeyPem' => Application_Utility::get_public_key(),
212 );
213 }
214
215 /**
216 * Get the User description.
217 *
218 * @return string The User description.
219 */
220 public function get_summary() {
221 return \sprintf(
222 /* translators: %s: Domain of the site */
223 \__( 'This is the Application Actor for %s.', 'activitypub' ),
224 home_host()
225 );
226 }
227
228 /**
229 * Returns the canonical URL of the object.
230 *
231 * @return string|null The canonical URL of the object.
232 */
233 public function get_canonical_url() {
234 return \home_url();
235 }
236 }
237