Skip to content

Commit a949900

Browse files
committed
API: Added examples for comments
Tweaked comment repo to avoid returning a lot of extra data on API update responses.
1 parent 9c4a922 commit a949900

File tree

8 files changed

+176
-0
lines changed

8 files changed

+176
-0
lines changed

app/Activity/CommentRepo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function create(Entity $entity, string $html, ?int $parentId, string $con
7474
ActivityService::add(ActivityType::COMMENT_CREATE, $comment);
7575
ActivityService::add(ActivityType::COMMENTED_ON, $entity);
7676

77+
$comment->refresh()->unsetRelations();
7778
return $comment;
7879
}
7980

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"page_id": 2646,
3+
"html": "<p>Can the title be updated?</p>",
4+
"content_ref": "bkmrk-page-title:7341676876991010:3-14"
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"html": "<p>Can this comment be updated??????</p>",
3+
"archived": true
4+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"id": 167,
3+
"commentable_id": 2646,
4+
"commentable_type": "page",
5+
"parent_id": null,
6+
"local_id": 29,
7+
"created_by": 1,
8+
"updated_by": 1,
9+
"created_at": "2025-10-24T14:05:41.000000Z",
10+
"updated_at": "2025-10-24T14:05:41.000000Z",
11+
"content_ref": "bkmrk-page-title:7341676876991010:3-14",
12+
"archived": false
13+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"data": [
3+
{
4+
"id": 1,
5+
"commentable_id": 2607,
6+
"commentable_type": "page",
7+
"parent_id": null,
8+
"local_id": 1,
9+
"content_ref": "",
10+
"created_by": 1,
11+
"updated_by": 1,
12+
"created_at": "2022-04-20T08:43:27.000000Z",
13+
"updated_at": "2022-04-20T08:43:27.000000Z"
14+
},
15+
{
16+
"id": 18,
17+
"commentable_id": 2607,
18+
"commentable_type": "page",
19+
"parent_id": 1,
20+
"local_id": 2,
21+
"content_ref": "",
22+
"created_by": 3,
23+
"updated_by": 3,
24+
"created_at": "2022-11-15T08:12:35.000000Z",
25+
"updated_at": "2022-11-15T08:12:35.000000Z"
26+
}
27+
],
28+
"total": 88
29+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"id": 22,
3+
"commentable_id": 2646,
4+
"commentable_type": "page",
5+
"html": "<p>This page looks great!<\/p>\n",
6+
"parent_id": null,
7+
"local_id": 2,
8+
"created_by": {
9+
"id": 1,
10+
"name": "Admin",
11+
"slug": "admin"
12+
},
13+
"updated_by": {
14+
"id": 1,
15+
"name": "Admin",
16+
"slug": "admin"
17+
},
18+
"created_at": "2023-06-07T07:50:56.000000Z",
19+
"updated_at": "2023-06-07T07:50:56.000000Z",
20+
"content_ref": "",
21+
"archived": false,
22+
"replies": [
23+
{
24+
"id": 34,
25+
"commentable_id": 2646,
26+
"commentable_type": "page",
27+
"html": "<p>Thanks for the comment!<\/p>\n",
28+
"parent_id": 2,
29+
"local_id": 10,
30+
"created_by": 2,
31+
"updated_by": 2,
32+
"created_at": "2023-06-07T13:46:25.000000Z",
33+
"updated_at": "2023-06-07T13:46:25.000000Z",
34+
"content_ref": "",
35+
"archived": false
36+
}
37+
]
38+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"id": 167,
3+
"commentable_id": 2646,
4+
"commentable_type": "page",
5+
"parent_id": null,
6+
"local_id": 29,
7+
"created_by": 1,
8+
"updated_by": 1,
9+
"created_at": "2025-10-24T14:05:41.000000Z",
10+
"updated_at": "2025-10-24T14:09:56.000000Z",
11+
"content_ref": "bkmrk-page-title:7341676876991010:3-14",
12+
"archived": true
13+
}

dev/api/responses/pages-read.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,79 @@
2929
"revision_count": 5,
3030
"template": false,
3131
"editor": "wysiwyg",
32+
"comments": {
33+
"active": [
34+
{
35+
"comment": {
36+
"id": 22,
37+
"commentable_id": 306,
38+
"commentable_type": "page",
39+
"html": "<p>Does this need revising?<\/p>\n",
40+
"parent_id": null,
41+
"local_id": 1,
42+
"created_by": {
43+
"id": 1,
44+
"name": "Admin",
45+
"slug": "admin"
46+
},
47+
"updated_by": 1,
48+
"created_at": "2023-06-07T07:50:56.000000Z",
49+
"updated_at": "2023-06-07T07:50:56.000000Z",
50+
"content_ref": "",
51+
"archived": false
52+
},
53+
"depth": 0,
54+
"children": [
55+
{
56+
"comment": {
57+
"id": 34,
58+
"commentable_id": 2646,
59+
"commentable_type": "page",
60+
"html": "<p>I think it's okay!<\/p>\n",
61+
"parent_id": 1,
62+
"local_id": 2,
63+
"created_by": {
64+
"id": 2,
65+
"name": "Editor",
66+
"slug": "editor"
67+
},
68+
"updated_by": 1,
69+
"created_at": "2023-06-07T13:46:25.000000Z",
70+
"updated_at": "2023-06-07T13:46:25.000000Z",
71+
"content_ref": "",
72+
"archived": false
73+
},
74+
"depth": 1,
75+
"children": []
76+
}
77+
]
78+
}
79+
],
80+
"archived": [
81+
{
82+
"comment": {
83+
"id": 21,
84+
"commentable_id": 2646,
85+
"commentable_type": "page",
86+
"html": "<p>The title needs to be fixed<\/p>\n",
87+
"parent_id": null,
88+
"local_id": 3,
89+
"created_by": {
90+
"id": 2,
91+
"name": "Editor",
92+
"slug": "editor"
93+
},
94+
"updated_by": 1,
95+
"created_at": "2023-06-07T07:50:49.000000Z",
96+
"updated_at": "2025-10-24T08:37:22.000000Z",
97+
"content_ref": "",
98+
"archived": true
99+
},
100+
"depth": 0,
101+
"children": []
102+
}
103+
]
104+
},
32105
"tags": [
33106
{
34107
"name": "Category",

0 commit comments

Comments
 (0)