| @@ -12,13 +12,10 @@ | ||
| 12 | 12 | use Activitypub\Collection\Followers; |
| 13 | 13 | use Activitypub\Collection\Following; |
| 14 | 14 | use Activitypub\Collection\Inbox; |
| 15 | 15 | use Activitypub\Collection\Outbox; |
| 16 | +use Activitypub\Collection\Posts; | |
| 16 | 17 | use Activitypub\Collection\Remote_Actors; |
| 17 | -use Activitypub\Collection\Remote_Posts; | |
| 18 | -use Activitypub\OAuth\Client; | |
| 19 | -use Activitypub\OAuth\Scope; | |
| 20 | -use Activitypub\OAuth\Token; | |
| 21 | 18 | |
| 22 | 19 | /** |
| 23 | 20 | * Post Types class. |
| 24 | 21 | */ |
| @@ -32,10 +29,8 @@ | ||
| 32 | 29 | \add_action( 'init', array( self::class, 'register_outbox_post_type' ), 11 ); |
| 33 | 30 | \add_action( 'init', array( self::class, 'register_post_post_type' ), 11 ); |
| 34 | 31 | \add_action( 'init', array( self::class, 'register_extra_fields_post_types' ), 11 ); |
| 35 | 32 | \add_action( 'init', array( self::class, 'register_activitypub_post_meta' ), 11 ); |
| 36 | - \add_action( 'init', array( self::class, 'register_oauth_post_types' ), 11 ); | |
| 37 | - \add_action( 'init', array( self::class, 'register_tombstone_post_type' ), 11 ); | |
| 38 | 33 | |
| 39 | 34 | \add_action( 'rest_api_init', array( self::class, 'register_ap_actor_rest_field' ) ); |
| 40 | 35 | \add_action( 'rest_api_init', array( self::class, 'register_ap_post_actor_rest_field' ) ); |
| 41 | 36 | \add_action( 'rest_api_init', array( self::class, 'register_ap_post_rest_params' ) ); |
| @@ -349,9 +344,9 @@ | ||
| 349 | 344 | * Register the Post post type. |
| 350 | 345 | */ |
| 351 | 346 | public static function register_post_post_type() { |
| 352 | 347 | \register_post_type( |
| 353 | - Remote_Posts::POST_TYPE, | |
| 348 | + Posts::POST_TYPE, | |
| 354 | 349 | array( |
| 355 | 350 | 'labels' => array( |
| 356 | 351 | 'name' => \_x( 'Posts', 'post_type plural name', 'activitypub' ), |
| 357 | 352 | 'singular_name' => \_x( 'Post', 'post_type single name', 'activitypub' ), |
| @@ -373,9 +368,9 @@ | ||
| 373 | 368 | ); |
| 374 | 369 | |
| 375 | 370 | \register_taxonomy( |
| 376 | 371 | 'ap_tag', |
| 377 | - array( Remote_Posts::POST_TYPE ), | |
| 372 | + array( Posts::POST_TYPE ), | |
| 378 | 373 | array( |
| 379 | 374 | 'public' => false, |
| 380 | 375 | 'query_var' => true, |
| 381 | 376 | 'show_in_rest' => true, |
| @@ -383,9 +378,9 @@ | ||
| 383 | 378 | ); |
| 384 | 379 | |
| 385 | 380 | \register_taxonomy( |
| 386 | 381 | 'ap_object_type', |
| 387 | - array( Remote_Posts::POST_TYPE ), | |
| 382 | + array( Posts::POST_TYPE ), | |
| 388 | 383 | array( |
| 389 | 384 | 'public' => false, |
| 390 | 385 | 'query_var' => true, |
| 391 | 386 | 'show_in_rest' => true, |
| @@ -392,9 +387,9 @@ | ||
| 392 | 387 | ) |
| 393 | 388 | ); |
| 394 | 389 | |
| 395 | 390 | \register_post_meta( |
| 396 | - Remote_Posts::POST_TYPE, | |
| 391 | + Posts::POST_TYPE, | |
| 397 | 392 | '_activitypub_remote_actor_id', |
| 398 | 393 | array( |
| 399 | 394 | 'type' => 'integer', |
| 400 | 395 | 'single' => true, |
| @@ -403,9 +398,9 @@ | ||
| 403 | 398 | ) |
| 404 | 399 | ); |
| 405 | 400 | |
| 406 | 401 | \register_post_meta( |
| 407 | - Remote_Posts::POST_TYPE, | |
| 402 | + Posts::POST_TYPE, | |
| 408 | 403 | '_activitypub_user_id', |
| 409 | 404 | array( |
| 410 | 405 | 'type' => 'integer', |
| 411 | 406 | 'single' => true, |
| @@ -461,139 +456,8 @@ | ||
| 461 | 456 | \do_action( 'activitypub_after_register_post_type' ); |
| 462 | 457 | } |
| 463 | 458 | |
| 464 | 459 | /** |
| 465 | - * Register OAuth 2.0 post types for C2S support. | |
| 466 | - * | |
| 467 | - * Registers post type for OAuth clients. | |
| 468 | - * Note: Tokens are stored in user meta and authorization codes in transients. | |
| 469 | - */ | |
| 470 | - public static function register_oauth_post_types() { | |
| 471 | - // OAuth Clients post type. | |
| 472 | - \register_post_type( | |
| 473 | - Client::POST_TYPE, | |
| 474 | - array( | |
| 475 | - 'labels' => array( | |
| 476 | - 'name' => \_x( 'OAuth Clients', 'post_type plural name', 'activitypub' ), | |
| 477 | - 'singular_name' => \_x( 'OAuth Client', 'post_type single name', 'activitypub' ), | |
| 478 | - ), | |
| 479 | - 'public' => false, | |
| 480 | - 'show_in_rest' => false, | |
| 481 | - 'hierarchical' => false, | |
| 482 | - 'rewrite' => false, | |
| 483 | - 'query_var' => false, | |
| 484 | - 'delete_with_user' => false, | |
| 485 | - 'can_export' => true, | |
| 486 | - 'supports' => array( 'title', 'editor', 'custom-fields' ), | |
| 487 | - 'exclude_from_search' => true, | |
| 488 | - ) | |
| 489 | - ); | |
| 490 | - | |
| 491 | - // OAuth Client meta. | |
| 492 | - \register_post_meta( | |
| 493 | - Client::POST_TYPE, | |
| 494 | - '_activitypub_client_id', | |
| 495 | - array( | |
| 496 | - 'type' => 'string', | |
| 497 | - 'single' => true, | |
| 498 | - 'description' => 'Unique OAuth client identifier (UUID).', | |
| 499 | - 'sanitize_callback' => 'sanitize_text_field', | |
| 500 | - ) | |
| 501 | - ); | |
| 502 | - | |
| 503 | - \register_post_meta( | |
| 504 | - Client::POST_TYPE, | |
| 505 | - '_activitypub_client_secret_hash', | |
| 506 | - array( | |
| 507 | - 'type' => 'string', | |
| 508 | - 'single' => true, | |
| 509 | - 'description' => 'SHA-256 hash of the client secret (null for public clients).', | |
| 510 | - 'sanitize_callback' => 'sanitize_text_field', | |
| 511 | - ) | |
| 512 | - ); | |
| 513 | - | |
| 514 | - \register_post_meta( | |
| 515 | - Client::POST_TYPE, | |
| 516 | - '_activitypub_redirect_uris', | |
| 517 | - array( | |
| 518 | - 'type' => 'array', | |
| 519 | - 'single' => true, | |
| 520 | - 'description' => 'Allowed redirect URIs for this client.', | |
| 521 | - 'sanitize_callback' => static function ( $value ) { | |
| 522 | - if ( ! is_array( $value ) ) { | |
| 523 | - return array(); | |
| 524 | - } | |
| 525 | - return array_map( array( Sanitize::class, 'redirect_uri' ), $value ); | |
| 526 | - }, | |
| 527 | - ) | |
| 528 | - ); | |
| 529 | - | |
| 530 | - \register_post_meta( | |
| 531 | - Client::POST_TYPE, | |
| 532 | - '_activitypub_allowed_scopes', | |
| 533 | - array( | |
| 534 | - 'type' => 'array', | |
| 535 | - 'single' => true, | |
| 536 | - 'description' => 'Allowed OAuth scopes for this client.', | |
| 537 | - 'sanitize_callback' => array( Scope::class, 'sanitize' ), | |
| 538 | - ) | |
| 539 | - ); | |
| 540 | - | |
| 541 | - \register_post_meta( | |
| 542 | - Client::POST_TYPE, | |
| 543 | - '_activitypub_is_public', | |
| 544 | - array( | |
| 545 | - 'type' => 'boolean', | |
| 546 | - 'single' => true, | |
| 547 | - 'description' => 'Whether this is a public client (PKCE-only, no secret).', | |
| 548 | - 'sanitize_callback' => 'rest_sanitize_boolean', | |
| 549 | - 'default' => true, | |
| 550 | - ) | |
| 551 | - ); | |
| 552 | - | |
| 553 | - \register_post_meta( | |
| 554 | - Client::POST_TYPE, | |
| 555 | - Token::USER_META_KEY, | |
| 556 | - array( | |
| 557 | - 'type' => 'integer', | |
| 558 | - 'single' => false, | |
| 559 | - 'description' => 'User IDs that have active tokens for this client.', | |
| 560 | - 'sanitize_callback' => 'absint', | |
| 561 | - ) | |
| 562 | - ); | |
| 563 | - } | |
| 564 | - | |
| 565 | - /** | |
| 566 | - * Register the ap_tombstone post type. | |
| 567 | - * | |
| 568 | - * Stores local tombstone URLs out of the autoloaded options row. | |
| 569 | - * The post type is fully internal — never queried publicly, never shown in UI. | |
| 570 | - * | |
| 571 | - * @since 8.3.0 | |
| 572 | - */ | |
| 573 | - public static function register_tombstone_post_type() { | |
| 574 | - \register_post_type( | |
| 575 | - Tombstone::POST_TYPE, | |
| 576 | - array( | |
| 577 | - 'public' => false, | |
| 578 | - 'publicly_queryable' => false, | |
| 579 | - 'show_ui' => false, | |
| 580 | - 'show_in_menu' => false, | |
| 581 | - 'show_in_nav_menus' => false, | |
| 582 | - 'show_in_admin_bar' => false, | |
| 583 | - 'show_in_rest' => false, | |
| 584 | - 'exclude_from_search' => true, | |
| 585 | - 'has_archive' => false, | |
| 586 | - 'rewrite' => false, | |
| 587 | - 'query_var' => false, | |
| 588 | - 'can_export' => false, | |
| 589 | - 'delete_with_user' => false, | |
| 590 | - 'supports' => array(), | |
| 591 | - ) | |
| 592 | - ); | |
| 593 | - } | |
| 594 | - | |
| 595 | - /** | |
| 596 | 460 | * Register post meta for ActivityPub supported post types. |
| 597 | 461 | */ |
| 598 | 462 | public static function register_activitypub_post_meta() { |
| 599 | 463 | $ap_post_types = \get_post_types_by_support( 'activitypub' ); |
| @@ -808,9 +672,9 @@ | ||
| 808 | 672 | * Register a REST field for the ap_post post type to embed remote actor data. |
| 809 | 673 | */ |
| 810 | 674 | public static function register_ap_post_actor_rest_field() { |
| 811 | 675 | \register_rest_field( |
| 812 | - Remote_Posts::POST_TYPE, | |
| 676 | + Posts::POST_TYPE, | |
| 813 | 677 | 'actor_info', |
| 814 | 678 | array( |
| 815 | 679 | /** |
| 816 | 680 | * Get the remote actor data for an ap_post. |
| @@ -848,9 +712,9 @@ | ||
| 848 | 712 | * Register custom REST API parameters for ap_post endpoint. |
| 849 | 713 | */ |
| 850 | 714 | public static function register_ap_post_rest_params() { |
| 851 | 715 | \add_filter( |
| 852 | - 'rest_' . Remote_Posts::POST_TYPE . '_collection_params', | |
| 716 | + 'rest_' . Posts::POST_TYPE . '_collection_params', | |
| 853 | 717 | function ( $params ) { |
| 854 | 718 | $params['user_id'] = array( |
| 855 | 719 | 'description' => __( 'Filter posts by user ID (0 for site/blog actor).', 'activitypub' ), |
| 856 | 720 | 'type' => 'integer', |