1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-10-25 06:37:36 +03:00

API: Started building comments API endpoints

This commit is contained in:
Dan Brown
2025-10-22 14:58:29 +01:00
parent abe9c1e5a3
commit 082dbc9944
6 changed files with 112 additions and 10 deletions

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace BookStack\Activity\Controllers;
use BookStack\Activity\CommentRepo;
use BookStack\Http\ApiController;
use Illuminate\Http\JsonResponse;
class CommentApiController extends ApiController
{
// TODO - Add tree-style comment listing to page-show responses.
// TODO - list
// TODO - create
// TODO - read
// TODO - update
// TODO - delete
// TODO - Test visibility controls
// TODO - Test permissions of each action
// TODO - Support intro block for API docs so we can explain the
// properties for comments in a shared kind of way?
public function __construct(
protected CommentRepo $commentRepo,
) {
}
/**
* Get a listing of comments visible to the user.
*/
public function list(): JsonResponse
{
$query = $this->commentRepo->getQueryForVisible();
return $this->apiListingResponse($query, [
'id', 'commentable_id', 'commentable_type', 'parent_id', 'local_id', 'content_ref', 'created_by', 'updated_by', 'created_at', 'updated_at'
]);
}
}