PluginProbe
ActivityPub / 3.2.5
ActivityPub v3.2.5
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 +30 -71 2.1.03.2.5 View file →
@@ -2,12 +2,16 @@
2 2 namespace Activitypub\Model;
3 3
4 4 use WP_Query;
5 5 use WP_Error;
6 +use Activitypub\Migration;
6 7 use Activitypub\Signature;
8 +use Activitypub\Model\Blog;
9 +use Activitypub\Activity\Actor;
7 10 use Activitypub\Collection\Users;
8 -use Activitypub\Activity\Actor;
11 +use Activitypub\Collection\Extra_Fields;
9 12
13 +use function Activitypub\is_blog_public;
10 14 use function Activitypub\is_user_disabled;
11 15 use function Activitypub\get_rest_url_by_path;
12 16
13 17 class User extends Actor {
@@ -32,21 +36,8 @@
32 36 */
33 37 protected $featured;
34 38
35 39 /**
36 - * Moderators endpoint.
37 - *
38 - * @see https://join-lemmy.org/docs/contributors/05-federation.html
39 - *
40 - * @var string
41 - */
42 - protected $moderators;
43 -
44 - public function get_type() {
45 - return 'Person';
46 - }
47 -
48 - /**
49 40 * If the User is discoverable.
50 41 *
51 42 * @see https://docs.joinmastodon.org/spec/activitypub/#discoverable
52 43 *
@@ -71,16 +62,11 @@
71 62 * @var string<url>
72 63 */
73 64 protected $webfinger;
74 65
75 - /**
76 - * Restrict posting to mods
77 - *
78 - * @see https://join-lemmy.org/docs/contributors/05-federation.html
79 - *
80 - * @var boolean
81 - */
82 - protected $posting_restricted_to_mods = null;
66 + public function get_type() {
67 + return 'Person';
68 + }
83 69
84 70 public static function from_wp_user( $user_id ) {
85 71 if ( is_user_disabled( $user_id ) ) {
86 72 return new WP_Error(
@@ -119,9 +105,9 @@
119 105 *
120 106 * @return string The User-Description.
121 107 */
122 108 public function get_summary() {
123 - $description = get_user_meta( $this->_id, 'activitypub_user_description', true );
109 + $description = get_user_option( 'activitypub_description', $this->_id );
124 110 if ( empty( $description ) ) {
125 111 $description = get_user_meta( $this->_id, 'description', true );
126 112 }
127 113 return \wpautop( \wp_kses( $description, 'default' ) );
@@ -163,13 +149,23 @@
163 149 );
164 150 }
165 151
166 152 public function get_image() {
167 - if ( \has_header_image() ) {
168 - $image = \esc_url( \get_header_image() );
153 + $header_image = get_user_option( 'activitypub_header_image', $this->_id );
154 + $image_url = null;
155 +
156 + if ( $header_image ) {
157 + $image_url = \wp_get_attachment_url( $header_image );
158 + }
159 +
160 + if ( ! $image_url && \has_header_image() ) {
161 + $image_url = \get_header_image();
162 + }
163 +
164 + if ( $image_url ) {
169 165 return array(
170 166 'type' => 'Image',
171 - 'url' => $image,
167 + 'url' => esc_url( $image_url ),
172 168 );
173 169 }
174 170
175 171 return null;
@@ -192,9 +188,9 @@
192 188 *
193 189 * @return string The Inbox-Endpoint.
194 190 */
195 191 public function get_inbox() {
196 - return get_rest_url_by_path( sprintf( 'users/%d/inbox', $this->get__id() ) );
192 + return get_rest_url_by_path( sprintf( 'actors/%d/inbox', $this->get__id() ) );
197 193 }
198 194
199 195 /**
200 196 * Returns the Outbox-API-Endpoint.
@@ -201,9 +197,9 @@
201 197 *
202 198 * @return string The Outbox-Endpoint.
203 199 */
204 200 public function get_outbox() {
205 - return get_rest_url_by_path( sprintf( 'users/%d/outbox', $this->get__id() ) );
201 + return get_rest_url_by_path( sprintf( 'actors/%d/outbox', $this->get__id() ) );
206 202 }
207 203
208 204 /**
209 205 * Returns the Followers-API-Endpoint.
@@ -210,9 +206,9 @@
210 206 *
211 207 * @return string The Followers-Endpoint.
212 208 */
213 209 public function get_followers() {
214 - return get_rest_url_by_path( sprintf( 'users/%d/followers', $this->get__id() ) );
210 + return get_rest_url_by_path( sprintf( 'actors/%d/followers', $this->get__id() ) );
215 211 }
216 212
217 213 /**
218 214 * Returns the Following-API-Endpoint.
@@ -219,9 +215,9 @@
219 215 *
220 216 * @return string The Following-Endpoint.
221 217 */
222 218 public function get_following() {
223 - return get_rest_url_by_path( sprintf( 'users/%d/following', $this->get__id() ) );
219 + return get_rest_url_by_path( sprintf( 'actors/%d/following', $this->get__id() ) );
224 220 }
225 221
226 222 /**
227 223 * Returns the Featured-API-Endpoint.
@@ -228,9 +224,9 @@
228 224 *
229 225 * @return string The Featured-Endpoint.
230 226 */
231 227 public function get_featured() {
232 - return get_rest_url_by_path( sprintf( 'users/%d/collections/featured', $this->get__id() ) );
228 + return get_rest_url_by_path( sprintf( 'actors/%d/collections/featured', $this->get__id() ) );
233 229 }
234 230
235 231 public function get_endpoints() {
236 232 $endpoints = null;
@@ -249,43 +245,10 @@
249 245 *
250 246 * @return array The extended User-Output.
251 247 */
252 248 public function get_attachment() {
253 - $array = array();
254 -
255 - $array[] = array(
256 - 'type' => 'PropertyValue',
257 - 'name' => \__( 'Blog', 'activitypub' ),
258 - 'value' => \html_entity_decode(
259 - '<a rel="me" title="' . \esc_attr( \home_url( '/' ) ) . '" target="_blank" href="' . \home_url( '/' ) . '">' . \wp_parse_url( \home_url( '/' ), \PHP_URL_HOST ) . '</a>',
260 - \ENT_QUOTES,
261 - 'UTF-8'
262 - ),
263 - );
264 -
265 - $array[] = array(
266 - 'type' => 'PropertyValue',
267 - 'name' => \__( 'Profile', 'activitypub' ),
268 - 'value' => \html_entity_decode(
269 - '<a rel="me" title="' . \esc_attr( \get_author_posts_url( $this->get__id() ) ) . '" target="_blank" href="' . \get_author_posts_url( $this->get__id() ) . '">' . \wp_parse_url( \get_author_posts_url( $this->get__id() ), \PHP_URL_HOST ) . '</a>',
270 - \ENT_QUOTES,
271 - 'UTF-8'
272 - ),
273 - );
274 -
275 - if ( \get_the_author_meta( 'user_url', $this->get__id() ) ) {
276 - $array[] = array(
277 - 'type' => 'PropertyValue',
278 - 'name' => \__( 'Website', 'activitypub' ),
279 - 'value' => \html_entity_decode(
280 - '<a rel="me" title="' . \esc_attr( \get_the_author_meta( 'user_url', $this->get__id() ) ) . '" target="_blank" href="' . \get_the_author_meta( 'user_url', $this->get__id() ) . '">' . \wp_parse_url( \get_the_author_meta( 'user_url', $this->get__id() ), \PHP_URL_HOST ) . '</a>',
281 - \ENT_QUOTES,
282 - 'UTF-8'
283 - ),
284 - );
285 - }
286 -
287 - return $array;
249 + $extra_fields = Extra_Fields::get_actor_fields( $this->_id );
250 + return Extra_Fields::fields_to_attachments( $extra_fields );
288 251 }
289 252
290 253 /**
291 254 * Returns a user@domain type of identifier for the user.
@@ -295,12 +258,8 @@
295 258 public function get_webfinger() {
296 259 return $this->get_preferred_username() . '@' . \wp_parse_url( \home_url(), \PHP_URL_HOST );
297 260 }
298 261
299 - public function get_resource() {
300 - return $this->get_webfinger();
301 - }
302 -
303 262 public function get_canonical_url() {
304 263 return $this->get_url();
305 264 }
306 265
@@ -312,9 +271,9 @@
312 271 return array();
313 272 }
314 273
315 274 public function get_indexable() {
316 - if ( \get_option( 'blog_public', 1 ) ) {
275 + if ( is_blog_public() ) {
317 276 return true;
318 277 } else {
319 278 return false;
320 279 }