mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-11-06 00:50:36 +03:00
API: Added examples for comments
Tweaked comment repo to avoid returning a lot of extra data on API update responses.
This commit is contained in:
@@ -74,6 +74,7 @@ class CommentRepo
|
||||
ActivityService::add(ActivityType::COMMENT_CREATE, $comment);
|
||||
ActivityService::add(ActivityType::COMMENTED_ON, $entity);
|
||||
|
||||
$comment->refresh()->unsetRelations();
|
||||
return $comment;
|
||||
}
|
||||
|
||||
|
||||
5
dev/api/requests/comments-create.json
Normal file
5
dev/api/requests/comments-create.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"page_id": 2646,
|
||||
"html": "<p>Can the title be updated?</p>",
|
||||
"content_ref": "bkmrk-page-title:7341676876991010:3-14"
|
||||
}
|
||||
4
dev/api/requests/comments-update.json
Normal file
4
dev/api/requests/comments-update.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"html": "<p>Can this comment be updated??????</p>",
|
||||
"archived": true
|
||||
}
|
||||
13
dev/api/responses/comments-create.json
Normal file
13
dev/api/responses/comments-create.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"id": 167,
|
||||
"commentable_id": 2646,
|
||||
"commentable_type": "page",
|
||||
"parent_id": null,
|
||||
"local_id": 29,
|
||||
"created_by": 1,
|
||||
"updated_by": 1,
|
||||
"created_at": "2025-10-24T14:05:41.000000Z",
|
||||
"updated_at": "2025-10-24T14:05:41.000000Z",
|
||||
"content_ref": "bkmrk-page-title:7341676876991010:3-14",
|
||||
"archived": false
|
||||
}
|
||||
29
dev/api/responses/comments-list.json
Normal file
29
dev/api/responses/comments-list.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"id": 1,
|
||||
"commentable_id": 2607,
|
||||
"commentable_type": "page",
|
||||
"parent_id": null,
|
||||
"local_id": 1,
|
||||
"content_ref": "",
|
||||
"created_by": 1,
|
||||
"updated_by": 1,
|
||||
"created_at": "2022-04-20T08:43:27.000000Z",
|
||||
"updated_at": "2022-04-20T08:43:27.000000Z"
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"commentable_id": 2607,
|
||||
"commentable_type": "page",
|
||||
"parent_id": 1,
|
||||
"local_id": 2,
|
||||
"content_ref": "",
|
||||
"created_by": 3,
|
||||
"updated_by": 3,
|
||||
"created_at": "2022-11-15T08:12:35.000000Z",
|
||||
"updated_at": "2022-11-15T08:12:35.000000Z"
|
||||
}
|
||||
],
|
||||
"total": 88
|
||||
}
|
||||
38
dev/api/responses/comments-read.json
Normal file
38
dev/api/responses/comments-read.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"id": 22,
|
||||
"commentable_id": 2646,
|
||||
"commentable_type": "page",
|
||||
"html": "<p>This page looks great!<\/p>\n",
|
||||
"parent_id": null,
|
||||
"local_id": 2,
|
||||
"created_by": {
|
||||
"id": 1,
|
||||
"name": "Admin",
|
||||
"slug": "admin"
|
||||
},
|
||||
"updated_by": {
|
||||
"id": 1,
|
||||
"name": "Admin",
|
||||
"slug": "admin"
|
||||
},
|
||||
"created_at": "2023-06-07T07:50:56.000000Z",
|
||||
"updated_at": "2023-06-07T07:50:56.000000Z",
|
||||
"content_ref": "",
|
||||
"archived": false,
|
||||
"replies": [
|
||||
{
|
||||
"id": 34,
|
||||
"commentable_id": 2646,
|
||||
"commentable_type": "page",
|
||||
"html": "<p>Thanks for the comment!<\/p>\n",
|
||||
"parent_id": 2,
|
||||
"local_id": 10,
|
||||
"created_by": 2,
|
||||
"updated_by": 2,
|
||||
"created_at": "2023-06-07T13:46:25.000000Z",
|
||||
"updated_at": "2023-06-07T13:46:25.000000Z",
|
||||
"content_ref": "",
|
||||
"archived": false
|
||||
}
|
||||
]
|
||||
}
|
||||
13
dev/api/responses/comments-update.json
Normal file
13
dev/api/responses/comments-update.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"id": 167,
|
||||
"commentable_id": 2646,
|
||||
"commentable_type": "page",
|
||||
"parent_id": null,
|
||||
"local_id": 29,
|
||||
"created_by": 1,
|
||||
"updated_by": 1,
|
||||
"created_at": "2025-10-24T14:05:41.000000Z",
|
||||
"updated_at": "2025-10-24T14:09:56.000000Z",
|
||||
"content_ref": "bkmrk-page-title:7341676876991010:3-14",
|
||||
"archived": true
|
||||
}
|
||||
@@ -29,6 +29,79 @@
|
||||
"revision_count": 5,
|
||||
"template": false,
|
||||
"editor": "wysiwyg",
|
||||
"comments": {
|
||||
"active": [
|
||||
{
|
||||
"comment": {
|
||||
"id": 22,
|
||||
"commentable_id": 306,
|
||||
"commentable_type": "page",
|
||||
"html": "<p>Does this need revising?<\/p>\n",
|
||||
"parent_id": null,
|
||||
"local_id": 1,
|
||||
"created_by": {
|
||||
"id": 1,
|
||||
"name": "Admin",
|
||||
"slug": "admin"
|
||||
},
|
||||
"updated_by": 1,
|
||||
"created_at": "2023-06-07T07:50:56.000000Z",
|
||||
"updated_at": "2023-06-07T07:50:56.000000Z",
|
||||
"content_ref": "",
|
||||
"archived": false
|
||||
},
|
||||
"depth": 0,
|
||||
"children": [
|
||||
{
|
||||
"comment": {
|
||||
"id": 34,
|
||||
"commentable_id": 2646,
|
||||
"commentable_type": "page",
|
||||
"html": "<p>I think it's okay!<\/p>\n",
|
||||
"parent_id": 1,
|
||||
"local_id": 2,
|
||||
"created_by": {
|
||||
"id": 2,
|
||||
"name": "Editor",
|
||||
"slug": "editor"
|
||||
},
|
||||
"updated_by": 1,
|
||||
"created_at": "2023-06-07T13:46:25.000000Z",
|
||||
"updated_at": "2023-06-07T13:46:25.000000Z",
|
||||
"content_ref": "",
|
||||
"archived": false
|
||||
},
|
||||
"depth": 1,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"archived": [
|
||||
{
|
||||
"comment": {
|
||||
"id": 21,
|
||||
"commentable_id": 2646,
|
||||
"commentable_type": "page",
|
||||
"html": "<p>The title needs to be fixed<\/p>\n",
|
||||
"parent_id": null,
|
||||
"local_id": 3,
|
||||
"created_by": {
|
||||
"id": 2,
|
||||
"name": "Editor",
|
||||
"slug": "editor"
|
||||
},
|
||||
"updated_by": 1,
|
||||
"created_at": "2023-06-07T07:50:49.000000Z",
|
||||
"updated_at": "2025-10-24T08:37:22.000000Z",
|
||||
"content_ref": "",
|
||||
"archived": true
|
||||
},
|
||||
"depth": 0,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "Category",
|
||||
|
||||
Reference in New Issue
Block a user