| @@ -9,10 +9,8 @@ | ||
| 9 | 9 | |
| 10 | 10 | use Activitypub\Comment; |
| 11 | 11 | use Activitypub\Webfinger; |
| 12 | 12 | |
| 13 | -use function Activitypub\is_post_publicly_queryable; | |
| 14 | - | |
| 15 | 13 | /** |
| 16 | 14 | * Comments_Controller class. |
| 17 | 15 | * |
| 18 | 16 | * @author Matthias Pfefferle |
| @@ -31,9 +29,9 @@ | ||
| 31 | 29 | * The base of this controller's route. |
| 32 | 30 | * |
| 33 | 31 | * @var string |
| 34 | 32 | */ |
| 35 | - protected $rest_base = 'comments/(?P<comment_id>[\d]+)'; | |
| 33 | + protected $rest_base = 'comments/(?P<comment_id>[-]?\d+)'; | |
| 36 | 34 | |
| 37 | 35 | /** |
| 38 | 36 | * Register routes. |
| 39 | 37 | */ |
| @@ -45,9 +43,8 @@ | ||
| 45 | 43 | 'args' => array( |
| 46 | 44 | 'comment_id' => array( |
| 47 | 45 | 'description' => 'The ID of the comment.', |
| 48 | 46 | 'type' => 'integer', |
| 49 | - 'minimum' => 1, | |
| 50 | 47 | 'required' => true, |
| 51 | 48 | 'validate_callback' => array( $this, 'validate_comment' ), |
| 52 | 49 | ), |
| 53 | 50 | ), |
| @@ -81,20 +78,11 @@ | ||
| 81 | 78 | if ( ! $comment ) { |
| 82 | 79 | return new \WP_Error( 'activitypub_comment_not_found', \__( 'Comment not found', 'activitypub' ), array( 'status' => 404 ) ); |
| 83 | 80 | } |
| 84 | 81 | |
| 85 | - /* | |
| 86 | - * A comment inherits the visibility of its parent post. Check this | |
| 87 | - * BEFORE the local-only guard below, so that any comment on a non- | |
| 88 | - * publicly-queryable parent returns the same "not found" shape — we | |
| 89 | - * never want an outsider to distinguish "comment exists but is local" | |
| 90 | - * from "comment missing" when the parent post is private. | |
| 91 | - */ | |
| 92 | - if ( ! is_post_publicly_queryable( $comment->comment_post_ID ) ) { | |
| 93 | - return new \WP_Error( 'activitypub_comment_not_found', \__( 'Comment not found', 'activitypub' ), array( 'status' => 404 ) ); | |
| 94 | - } | |
| 82 | + $is_local = Comment::is_local( $comment ); | |
| 95 | 83 | |
| 96 | - if ( Comment::is_local( $comment ) ) { | |
| 84 | + if ( $is_local ) { | |
| 97 | 85 | return new \WP_Error( 'activitypub_local_only_comment', \__( 'Comment is local only', 'activitypub' ), array( 'status' => 403 ) ); |
| 98 | 86 | } |
| 99 | 87 | |
| 100 | 88 | return true; |