]> BookStack Code Mirror - bookstack/blob - app/Activity/Controllers/CommentApiController.php
API: Started building comments API endpoints
[bookstack] / app / Activity / Controllers / CommentApiController.php
1 <?php
2
3 declare(strict_types=1);
4
5 namespace BookStack\Activity\Controllers;
6
7 use BookStack\Activity\CommentRepo;
8 use BookStack\Http\ApiController;
9 use Illuminate\Http\JsonResponse;
10
11 class CommentApiController extends ApiController
12 {
13     // TODO - Add tree-style comment listing to page-show responses.
14     // TODO - list
15     // TODO - create
16     // TODO - read
17     // TODO - update
18     // TODO - delete
19
20     // TODO - Test visibility controls
21     // TODO - Test permissions of each action
22
23     // TODO - Support intro block for API docs so we can explain the
24     //   properties for comments in a shared kind of way?
25
26     public function __construct(
27         protected CommentRepo $commentRepo,
28     ) {
29     }
30
31
32     /**
33      * Get a listing of comments visible to the user.
34      */
35     public function list(): JsonResponse
36     {
37         $query = $this->commentRepo->getQueryForVisible();
38
39         return $this->apiListingResponse($query, [
40             'id', 'commentable_id', 'commentable_type', 'parent_id', 'local_id', 'content_ref', 'created_by', 'updated_by', 'created_at', 'updated_at'
41         ]);
42     }
43 }