strapi-plugin-comments 2.0.0-beta.4 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +421 -72
- package/admin/src/components/DiscussionThread/index.js +9 -2
- package/admin/src/components/DiscussionThreadItem/index.js +27 -12
- package/admin/src/components/DiscussionThreadItemActions/index.js +61 -50
- package/admin/src/components/DiscussionThreadItemActions/styles.js +0 -4
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +81 -0
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.js +6 -0
- package/admin/src/components/DiscussionThreadItemMeta/index.js +16 -5
- package/admin/src/components/DiscussionThreadItemWarnings/index.js +16 -10
- package/admin/src/components/Nav/index.js +5 -1
- package/admin/src/components/ReportsReviewModal/index.js +5 -0
- package/admin/src/components/ReportsReviewTable/index.js +60 -52
- package/admin/src/components/icons/review.js +2 -2
- package/admin/src/index.js +1 -1
- package/admin/src/pages/Details/components/DetailsEntity/index.js +66 -0
- package/admin/src/pages/Details/components/DetailsFilters/index.js +37 -0
- package/admin/src/pages/Details/components/DetailsFilters/styles.js +8 -0
- package/admin/src/pages/Details/index.js +75 -42
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +69 -48
- package/admin/src/pages/Discover/components/DiscoverTableRow/styles.js +8 -0
- package/admin/src/pages/Discover/index.js +72 -56
- package/admin/src/pages/{Details/utils → utils}/api.js +15 -3
- package/admin/src/permissions.js +10 -8
- package/admin/src/translations/en.json +17 -4
- package/admin/src/utils/constants.js +3 -6
- package/admin/src/utils/getMessage.js +1 -1
- package/admin/src/utils/getRelatedGroups.js +1 -3
- package/admin/src/utils/index.js +5 -1
- package/admin/src/utils/renderEntryTitle.js +14 -0
- package/admin/src/utils/renderInitials.js +5 -0
- package/admin/src/utils/resolveCommentStatus.js +30 -0
- package/admin/src/utils/resolveCommentStatusColor.js +22 -0
- package/package.json +8 -3
- package/permissions.js +19 -0
- package/public/assets/logo.png +0 -0
- package/public/assets/preview.png +0 -0
- package/server/bootstrap.js +38 -2
- package/server/config/index.js +9 -3
- package/server/controllers/admin.js +3 -3
- package/server/controllers/client.js +4 -18
- package/server/controllers/utils/parsers.js +17 -0
- package/server/graphql/index.js +26 -0
- package/server/graphql/mutations/createAbuseReport.js +20 -0
- package/server/graphql/mutations/createComment.js +20 -0
- package/server/graphql/mutations/index.js +21 -0
- package/server/graphql/mutations/removeComment.js +20 -0
- package/server/graphql/mutations/updateComment.js +20 -0
- package/server/graphql/queries/findAllFlat.js +29 -0
- package/server/graphql/queries/findAllInHierarchy.js +31 -0
- package/server/graphql/queries/index.js +19 -0
- package/server/graphql/resolvers-config.js +10 -0
- package/server/graphql/types/comment-author-user.js +9 -0
- package/server/graphql/types/comment-author.js +9 -0
- package/server/graphql/types/comment-nested.js +16 -0
- package/server/graphql/types/comment.js +16 -0
- package/server/graphql/types/create-comment-author.js +9 -0
- package/server/graphql/types/create-comment.js +9 -0
- package/server/graphql/types/create-report.js +9 -0
- package/server/graphql/types/id.js +24 -0
- package/server/graphql/types/identify-comment-author.js +6 -0
- package/server/graphql/types/index.js +17 -0
- package/server/graphql/types/remove-comment.js +8 -0
- package/server/graphql/types/report-reason.js +10 -0
- package/server/graphql/types/report.js +11 -0
- package/server/graphql/types/update-comment.js +9 -0
- package/server/register.js +3 -1
- package/server/services/admin.js +42 -15
- package/server/services/client.js +54 -38
- package/server/services/common.js +38 -67
- package/server/services/graphql.js +190 -0
- package/server/services/index.js +2 -0
- package/server/services/utils/functions.js +24 -17
- package/server/utils/constants.js +3 -3
- package/strapi-server.js +33 -0
- package/admin/src/components/EntityDetails/index.js +0 -53
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img style="width: 150px; height: auto;" src="public/assets/logo.png" alt="Logo - Strapi Comments plugin" />
|
|
3
|
+
<h1>Strapi v4 - Comments plugin</h1>
|
|
4
|
+
<p>Powerfull Strapi based comments moderation tool for you and your users</p>
|
|
4
5
|
<a href="https://www.npmjs.org/package/strapi-plugin-comments">
|
|
5
6
|
<img src="https://img.shields.io/npm/v/strapi-plugin-comments/latest.svg" alt="NPM Version" />
|
|
6
7
|
</a>
|
|
@@ -13,15 +14,32 @@
|
|
|
13
14
|
<a href="https://codecov.io/gh/VirtusLab-Open-Source/strapi-plugin-comments">
|
|
14
15
|
<img src="https://codecov.io/gh/VirtusLab-Open-Source/strapi-plugin-comments/coverage.svg?branch=master" alt="codecov.io" />
|
|
15
16
|
</a>
|
|
16
|
-
</
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<div style="margin: 20px 0" align="center">
|
|
22
|
+
<img style="width: 100%; height: auto;" src="public/assets/preview.png" alt="UI preview" />
|
|
23
|
+
</div>
|
|
17
24
|
|
|
18
|
-
A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and more.
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
- **Stable** - [v1.0.4](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments)
|
|
22
|
-
- **Beta** - v4 support - [v2.0.0-beta.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/tree/feat/strapi-v4)
|
|
26
|
+
A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and much more.
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
## ✨ Features
|
|
29
|
+
|
|
30
|
+
- **Comments Public REST + GraphQL API:** Elegant, entirely customizable and a fully extensible admin panel.
|
|
31
|
+
- **Strapi & generic users:** Support for built-in & also generic non-Strapi users that might be the comments authors.
|
|
32
|
+
- **Any Content Type relation:** Comments can by linked to any of your Content Types by default. Simply, you're controlling it.
|
|
33
|
+
- **Moderation Panel:** Search & Filter through the bucket with your auditory comments. Manage them by blocking single ones or full threads. All in combined list & hierarchical tree view of threads.
|
|
34
|
+
- **Automated Bad Words filtering:** By detault end users are not allowed to post abusing comments where bad words have been used.
|
|
35
|
+
- **Abuse Reporting & Reviewing:** Don't allow inferior language, react to reports from your community, send email notifiactions about abuse reports
|
|
36
|
+
|
|
37
|
+
## ⚙️ Versions
|
|
38
|
+
|
|
39
|
+
- **Strapi v4** - (current) - [v2.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments)
|
|
40
|
+
- **Strapi v3** - [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/tree/strapi-v3)
|
|
41
|
+
|
|
42
|
+
## ⏳ Installation
|
|
25
43
|
|
|
26
44
|
(Use **yarn** to install this plugin within your Strapi project (recommended). [Install yarn with these docs](https://yarnpkg.com/lang/en/docs/install/).)
|
|
27
45
|
|
|
@@ -42,58 +60,79 @@ or just run Strapi in the development mode with `--watch-admin` option:
|
|
|
42
60
|
yarn develop --watch-admin
|
|
43
61
|
```
|
|
44
62
|
|
|
45
|
-
The **Comments** plugin should appear in the
|
|
63
|
+
The **Comments** plugin should appear in the navigation menu of Strapi after you run app again.
|
|
46
64
|
|
|
47
65
|
Enjoy 🎉
|
|
48
66
|
|
|
49
|
-
|
|
67
|
+
## 🖐 Requirements
|
|
50
68
|
|
|
51
69
|
Complete installation requirements are exact same as for Strapi itself and can be found in the documentation under [Installation Requirements](https://docs.strapi.io/developer-docs/latest/getting-started/introduction.html).
|
|
52
70
|
|
|
53
|
-
**
|
|
71
|
+
**Minimum environment requirements**
|
|
72
|
+
- Node.js `>=14.x.x`
|
|
73
|
+
- NPM `>=7.x.x`
|
|
54
74
|
|
|
55
|
-
|
|
75
|
+
In our minimum support we're following [official Node.js releases timelines](https://nodejs.org/en/about/releases/).
|
|
56
76
|
|
|
57
|
-
|
|
77
|
+
**Supported Strapi versions**:
|
|
58
78
|
|
|
59
|
-
|
|
79
|
+
- Strapi v4.0.5 (recently tested)
|
|
80
|
+
- Strapi v4.x
|
|
60
81
|
|
|
61
|
-
|
|
82
|
+
> This plugin is designed for **Strapi v4** and is not working with v3.x. To get version for **Strapi v3** install version [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/tree/strapi-v3).
|
|
62
83
|
|
|
63
|
-
|
|
64
|
-
- **Strapi & generic users:** Support for built-in & also generic non-Strapi users that might be the comments authors.
|
|
65
|
-
- **Any Content Type relation:** Comments can by linked to any of your Content Types by default. Simply, you're controlling it.
|
|
66
|
-
- **Moderation Panel:** Search & Filter through the bucket with your auditory comments. Manage them by blocking single ones or full threads. All in combined list & hierarchical tree view of threads.
|
|
67
|
-
- **Automated Bad Words filtering:** By detault end users are not allowed to post abusing comments where bad words have been used.
|
|
68
|
-
- **Abuse Reporting & Reviewing:** Don't allow inferior language, react to reports from your community, send email notifiactions about abuse reports
|
|
84
|
+
**We recommend always using the latest version of Strapi to start your new projects**.
|
|
69
85
|
|
|
70
|
-
## Configuration
|
|
86
|
+
## 🔧 Configuration
|
|
71
87
|
To setup amend default plugin configuration we recommend to put following snippet as part of `config/plugins.js` or `config/<env>/plugins.js` file. If the file does not exist yet, you have to create it manually. If you've got already configurations for other plugins stores by this way, use just the `comments` part within exising `plugins` item.
|
|
72
88
|
|
|
73
89
|
|
|
74
90
|
```js
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
module.exports = ({ env }) => ({
|
|
92
|
+
//...
|
|
93
|
+
comments: {
|
|
94
|
+
badWords: false,
|
|
95
|
+
moderatorRoles: ["Authenticated"],
|
|
96
|
+
approvalFlow: ['api::page.page'],
|
|
97
|
+
entryLabel: {
|
|
98
|
+
'*': ['Title', 'title', 'Name', 'name', 'Subject', 'subject'],
|
|
99
|
+
'api::page.page': ['MyField'],
|
|
100
|
+
},
|
|
101
|
+
reportReasons: {
|
|
102
|
+
'MY_CUSTOM_REASON': 'MY_CUSTOM_REASON',
|
|
103
|
+
},
|
|
82
104
|
},
|
|
83
|
-
|
|
84
|
-
|
|
105
|
+
//...
|
|
106
|
+
});
|
|
85
107
|
```
|
|
86
108
|
|
|
87
109
|
### Properties
|
|
88
110
|
- `badWords` - Enabled support for [bad words filtering](https://www.npmjs.com/package/bad-words). Can be turned off or overwritten using [options reference](https://www.npmjs.com/package/bad-words#constructor). Default value: `true`.
|
|
89
111
|
- `moderatorRoles` - Optional list of names of roles. Users with those roles will be notified by email when a new abuse report is created. This feature requires a built-in [Strapi email plugin](https://docs.strapi.io/developer-docs/latest/plugins/email.html) configured.
|
|
90
|
-
- `
|
|
112
|
+
- `approvalFlow` - list of Content Types which are supporting approval flow. Values must be in format like `'api::<collection name>.<content type name>'`. For not included, posted comments are going to be immediately visible.
|
|
113
|
+
- `entryLabel` - ordered list of property names per Content Type to generate related entity label. Keys must be in format like `'api::<collection name>.<content type name>'`. Default formatting set as `*`.
|
|
114
|
+
- `reportReasons` - set of enums you would like to use for issuing abuse reports. Provided by default `'BAD_LANGUAGE'`, `'DISCRIMINATION'` and `'OTHER'`.
|
|
91
115
|
|
|
92
116
|
## Additional GQL Configuration
|
|
117
|
+
All you need to do is to install and enable `@strapi/plugin-graphql` for you instance based on the **[official Strapi v4 docs](https://docs.strapi.io/developer-docs/latest/plugins/graphql.html#configurations)**.
|
|
118
|
+
|
|
119
|
+
See [available GQL specification section](#public-graphql-specification).
|
|
120
|
+
|
|
121
|
+
## 👤 RBAC
|
|
122
|
+
Plugin provides granular permissions based on Strapi RBAC functionality.
|
|
93
123
|
|
|
94
|
-
|
|
124
|
+
### Mandatory permissions
|
|
125
|
+
For any role different than **Super Admin**, to access the **Comments panel** you must set following permissions:
|
|
126
|
+
- _Plugins_ -> _Content-type-builder_ -> _Read_ - gives you ability to fetch Content Type schema
|
|
127
|
+
- _Plugins_ -> _Comments_ -> _Comments: Read_ - gives you the basic read access to **Comments Panel**
|
|
95
128
|
|
|
96
|
-
|
|
129
|
+
### Optional permissions
|
|
130
|
+
Feature / Capability focused permissions:
|
|
131
|
+
- _Plugins_ -> _Comments_ -> _Comments: Moderate_ - allows you to block, unblock, approve & reject comments
|
|
132
|
+
- _Plugins_ -> _Comments_ -> _Reports: Read_ - allows you to see the list of issued abuse reports against comments
|
|
133
|
+
- _Plugins_ -> _Comments_ -> _Reports: Moderate_ - allows you to review (resolve) issued abuse reports against comments
|
|
134
|
+
|
|
135
|
+
## Base Comment model
|
|
97
136
|
|
|
98
137
|
### Generic (non Strapi User)
|
|
99
138
|
```json
|
|
@@ -104,10 +143,14 @@ To setup amend default plugin configuration we recommend to put following snippe
|
|
|
104
143
|
"blockedThread": true,
|
|
105
144
|
"blockReason": null,
|
|
106
145
|
"authorUser": null,
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
|
|
146
|
+
"removed": null,
|
|
147
|
+
"approvalStatus": "APPROVED", // Only in case of enabled approval flow. Default: null
|
|
148
|
+
"author": {
|
|
149
|
+
"id": "207ccfdc-94ba-45eb-979c-790f6f49c392",
|
|
150
|
+
"name": "Joe Doe",
|
|
151
|
+
"email": "jdoe@sample.com",
|
|
152
|
+
"avatar": null,
|
|
153
|
+
},
|
|
111
154
|
"createdAt": "2020-07-14T20:13:01.649Z",
|
|
112
155
|
"updatedAt": "2020-07-14T20:13:01.670Z",
|
|
113
156
|
"related": {}, // Related content type entity
|
|
@@ -122,6 +165,8 @@ To setup amend default plugin configuration we recommend to put following snippe
|
|
|
122
165
|
"blocked": true,
|
|
123
166
|
"blockedThread": null,
|
|
124
167
|
"blockReason": null,
|
|
168
|
+
"removed": null,
|
|
169
|
+
"approvalStatus": "REJECTED", // Only in case of enabled approval flow. Default: null
|
|
125
170
|
"authorUser": {
|
|
126
171
|
"id": 1,
|
|
127
172
|
"username": "Sample User",
|
|
@@ -145,10 +190,12 @@ To setup amend default plugin configuration we recommend to put following snippe
|
|
|
145
190
|
|
|
146
191
|
```
|
|
147
192
|
|
|
148
|
-
## Public API specification
|
|
193
|
+
## 🕸️ Public REST API specification
|
|
149
194
|
|
|
150
195
|
### Get Comments
|
|
151
196
|
|
|
197
|
+
*GraphQL equivalent: [Public GraphQL API -> Get Comments](#get-comments-1)*
|
|
198
|
+
|
|
152
199
|
`GET <host>/comments/api::<collection name>.<content type name>:<entity id>`
|
|
153
200
|
|
|
154
201
|
Return a hierarchical tree structure of comments for specified instance of Content Type like for example `Page` with `ID: 1`
|
|
@@ -157,24 +204,28 @@ Return a hierarchical tree structure of comments for specified instance of Conte
|
|
|
157
204
|
|
|
158
205
|
**Example response body**
|
|
159
206
|
|
|
160
|
-
```
|
|
207
|
+
```json
|
|
161
208
|
[
|
|
162
209
|
{
|
|
163
|
-
-- Comment Model fields ---,
|
|
210
|
+
// -- Comment Model fields ---,
|
|
164
211
|
children: [
|
|
165
212
|
{
|
|
166
|
-
-- Comment Model fields ---,
|
|
167
|
-
children: [
|
|
213
|
+
// -- Comment Model fields ---,
|
|
214
|
+
children: [
|
|
215
|
+
// ...
|
|
216
|
+
]
|
|
168
217
|
},
|
|
169
|
-
...
|
|
218
|
+
// ...
|
|
170
219
|
]
|
|
171
220
|
},
|
|
172
|
-
...
|
|
221
|
+
// ...
|
|
173
222
|
]
|
|
174
223
|
```
|
|
175
224
|
|
|
176
225
|
### Get Comments (flat structure)
|
|
177
226
|
|
|
227
|
+
*GraphQL equivalent: [Public GraphQL API -> Get Comments (flat structure)](#get-comments-flat-structure-1)*
|
|
228
|
+
|
|
178
229
|
`GET <host>/comments/api::<collection name>.<content type name>:<entity id>/flat`
|
|
179
230
|
|
|
180
231
|
Return a flat structure of comments for specified instance of Content Type like for example `Page` with `ID: 1`
|
|
@@ -183,15 +234,15 @@ Return a flat structure of comments for specified instance of Content Type like
|
|
|
183
234
|
|
|
184
235
|
**Example response body**
|
|
185
236
|
|
|
186
|
-
```
|
|
237
|
+
```json
|
|
187
238
|
[
|
|
188
239
|
{
|
|
189
|
-
-- Comment Model fields ---
|
|
240
|
+
// -- Comment Model fields ---
|
|
190
241
|
},
|
|
191
242
|
{
|
|
192
|
-
-- Comment Model fields ---
|
|
243
|
+
// -- Comment Model fields ---
|
|
193
244
|
},
|
|
194
|
-
...
|
|
245
|
+
// ...
|
|
195
246
|
]
|
|
196
247
|
```
|
|
197
248
|
|
|
@@ -201,6 +252,8 @@ Return a flat structure of comments for specified instance of Content Type like
|
|
|
201
252
|
|
|
202
253
|
### Post a Comment
|
|
203
254
|
|
|
255
|
+
*GraphQL equivalent: [Public GraphQL API -> Post a Comments](#post-a-comment-1)*
|
|
256
|
+
|
|
204
257
|
`POST <host>/comments/api::<collection name>.<content type name>:<entity id>`
|
|
205
258
|
|
|
206
259
|
Posts a Comment related to specified instance of Content Type like for example `Page` with `ID: 1`
|
|
@@ -210,7 +263,7 @@ Posts a Comment related to specified instance of Content Type like for example `
|
|
|
210
263
|
**Example request body**
|
|
211
264
|
|
|
212
265
|
*Generic (non Strapi User)*
|
|
213
|
-
```
|
|
266
|
+
```json
|
|
214
267
|
{
|
|
215
268
|
"author": {
|
|
216
269
|
"id": "<any ID like value>",
|
|
@@ -220,25 +273,23 @@ Posts a Comment related to specified instance of Content Type like for example `
|
|
|
220
273
|
},
|
|
221
274
|
"content": "My sample response",
|
|
222
275
|
"threadOf": 2, // id of comment we would like to start / continue the thread (Optional)
|
|
223
|
-
"related": "api::page.page:1"
|
|
224
276
|
}
|
|
225
277
|
```
|
|
226
278
|
|
|
227
279
|
*Strapi user*
|
|
228
|
-
```
|
|
280
|
+
```json
|
|
229
281
|
{
|
|
230
282
|
"authorUser": 1, // id of a author user. Optional in case of 'enableUsers: true' in the plugin configuration
|
|
231
283
|
"content": "My sample response",
|
|
232
284
|
"threadOf": 2, // id of comment we would like to start / continue the thread (Optional)
|
|
233
|
-
"related": "api::page.page:1"
|
|
234
285
|
}
|
|
235
286
|
```
|
|
236
287
|
|
|
237
288
|
**Example response body**
|
|
238
289
|
|
|
239
|
-
```
|
|
290
|
+
```json
|
|
240
291
|
{
|
|
241
|
-
-- Comment Model fields ---
|
|
292
|
+
// -- Comment Model fields ---
|
|
242
293
|
}
|
|
243
294
|
```
|
|
244
295
|
|
|
@@ -248,6 +299,8 @@ Posts a Comment related to specified instance of Content Type like for example `
|
|
|
248
299
|
|
|
249
300
|
### Update Comment
|
|
250
301
|
|
|
302
|
+
*GraphQL equivalent: [Public GraphQL API -> Update Comments](#update-comment-1)*
|
|
303
|
+
|
|
251
304
|
`PUT <host>/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>`
|
|
252
305
|
|
|
253
306
|
Updates a specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1`
|
|
@@ -257,7 +310,7 @@ Updates a specified Comment content based on it `commentId` and related to speci
|
|
|
257
310
|
**Example request body**
|
|
258
311
|
|
|
259
312
|
*Generic (non Strapi User)*
|
|
260
|
-
```
|
|
313
|
+
```json
|
|
261
314
|
{
|
|
262
315
|
"author": {
|
|
263
316
|
"id": "<any ID like value>"
|
|
@@ -267,7 +320,7 @@ Updates a specified Comment content based on it `commentId` and related to speci
|
|
|
267
320
|
```
|
|
268
321
|
|
|
269
322
|
*Strapi user*
|
|
270
|
-
```
|
|
323
|
+
```json
|
|
271
324
|
{
|
|
272
325
|
"authorUser": 1, // id of a author user. Optional in case of 'enableUsers: true' in the plugin configuration
|
|
273
326
|
"content": "My sample response"
|
|
@@ -276,9 +329,9 @@ Updates a specified Comment content based on it `commentId` and related to speci
|
|
|
276
329
|
|
|
277
330
|
**Example response body**
|
|
278
331
|
|
|
279
|
-
```
|
|
332
|
+
```json
|
|
280
333
|
{
|
|
281
|
-
-- Comment Model fields ---
|
|
334
|
+
// -- Comment Model fields ---
|
|
282
335
|
}
|
|
283
336
|
```
|
|
284
337
|
|
|
@@ -289,6 +342,8 @@ Updates a specified Comment content based on it `commentId` and related to speci
|
|
|
289
342
|
|
|
290
343
|
### Delete Comment
|
|
291
344
|
|
|
345
|
+
*GraphQL equivalent: [Public GraphQL API -> Delete Comment](#delete-comment-1)*
|
|
346
|
+
|
|
292
347
|
`DELETE <host>/comments/api::<collection name>.<content type name>:<entity id>/<commentId>?authorId=<authorId>`
|
|
293
348
|
|
|
294
349
|
Deletes a specified Comment based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1`.
|
|
@@ -297,9 +352,9 @@ Deletes a specified Comment based on it `commentId` and related to specified ins
|
|
|
297
352
|
|
|
298
353
|
**Example response body**
|
|
299
354
|
|
|
300
|
-
```
|
|
355
|
+
```json
|
|
301
356
|
{
|
|
302
|
-
-- Empty Response ---
|
|
357
|
+
// -- Empty Response ---
|
|
303
358
|
}
|
|
304
359
|
```
|
|
305
360
|
|
|
@@ -308,7 +363,9 @@ Deletes a specified Comment based on it `commentId` and related to specified ins
|
|
|
308
363
|
- `409` - Conflict. Occurs when trying to delete a non existing comment.
|
|
309
364
|
|
|
310
365
|
|
|
311
|
-
### Report
|
|
366
|
+
### Issue Abuse Report against specified Comment
|
|
367
|
+
|
|
368
|
+
*GraphQL equivalent: [Public GraphQL API -> Issue Abuse Report against specified Comment](#issue-abuse-report-against-specified-comment-1)*
|
|
312
369
|
|
|
313
370
|
`POST <host>/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>/report-abuse`
|
|
314
371
|
|
|
@@ -318,20 +375,20 @@ Reports abuse in specified Comment content based on it `commentId` and related t
|
|
|
318
375
|
|
|
319
376
|
**Example request body**
|
|
320
377
|
|
|
321
|
-
```
|
|
378
|
+
```json
|
|
322
379
|
{
|
|
323
380
|
"reason": "<reason enum>",
|
|
324
381
|
"content": "This comment is not relevant"
|
|
325
382
|
}
|
|
326
383
|
```
|
|
327
384
|
|
|
328
|
-
*Available reason enums:* `
|
|
385
|
+
*Available reason enums:* `BAD_WORDS`, `OTHER`, `DISCRIMINATION` (want more? See [configuration section](#configuration).)
|
|
329
386
|
|
|
330
387
|
**Example response body**
|
|
331
388
|
|
|
332
|
-
```
|
|
389
|
+
```json
|
|
333
390
|
{
|
|
334
|
-
-- Comment Abuse Report fields ---
|
|
391
|
+
// -- Comment Abuse Report fields ---
|
|
335
392
|
}
|
|
336
393
|
```
|
|
337
394
|
|
|
@@ -339,15 +396,307 @@ Reports abuse in specified Comment content based on it `commentId` and related t
|
|
|
339
396
|
- `200` - Successful. Response with reported abuse.
|
|
340
397
|
- `409` - Conflict. Occurs when trying to report an abuse to a non existing comment.
|
|
341
398
|
|
|
342
|
-
##
|
|
399
|
+
## 🕸️ Public GraphQL specification
|
|
400
|
+
|
|
401
|
+
> *To test all queries and understand the schemas use GraphQL Playground exposed by `@strapi/plugin-graphql` on `http://localhost:1337/graphql`*
|
|
402
|
+
|
|
403
|
+
### Get Comments
|
|
404
|
+
|
|
405
|
+
*REST API equivalent: [Public REST API -> Get Comments](#get-comments)*
|
|
406
|
+
|
|
407
|
+
**Example request**
|
|
408
|
+
|
|
409
|
+
```graphql
|
|
410
|
+
query {
|
|
411
|
+
findAllFlat(
|
|
412
|
+
relation: "api::page.page:1"
|
|
413
|
+
filters: { content: { contains: "Test" } }
|
|
414
|
+
) {
|
|
415
|
+
id
|
|
416
|
+
content
|
|
417
|
+
blocked
|
|
418
|
+
threadOf {
|
|
419
|
+
id
|
|
420
|
+
}
|
|
421
|
+
author {
|
|
422
|
+
id
|
|
423
|
+
name
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
**Example response**
|
|
430
|
+
|
|
431
|
+
```json
|
|
432
|
+
{
|
|
433
|
+
"data": {
|
|
434
|
+
"findAllFlat": [
|
|
435
|
+
{
|
|
436
|
+
"id": 3,
|
|
437
|
+
"content": "Test",
|
|
438
|
+
"blocked": false,
|
|
439
|
+
"threadOf": null,
|
|
440
|
+
"author": {
|
|
441
|
+
"id": "123456",
|
|
442
|
+
"name": "Joe Doe"
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
// ...
|
|
446
|
+
]
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### Get Comments (flat structure)
|
|
451
|
+
|
|
452
|
+
*REST API equivalent: [Public REST API -> Get Comments (flat structure)](#get-comments-flat-structure)*
|
|
453
|
+
|
|
454
|
+
**Example request**
|
|
455
|
+
|
|
456
|
+
```graphql
|
|
457
|
+
query {
|
|
458
|
+
findAllInHierarchy(relation: "api::page.page:1") {
|
|
459
|
+
id
|
|
460
|
+
content
|
|
461
|
+
blocked
|
|
462
|
+
children {
|
|
463
|
+
id
|
|
464
|
+
content
|
|
465
|
+
}
|
|
466
|
+
threadOf {
|
|
467
|
+
id
|
|
468
|
+
}
|
|
469
|
+
author {
|
|
470
|
+
id
|
|
471
|
+
name
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
**Example response**
|
|
478
|
+
|
|
479
|
+
```json
|
|
480
|
+
{
|
|
481
|
+
"data": {
|
|
482
|
+
"findAllInHierarchy": [
|
|
483
|
+
{
|
|
484
|
+
"id": 1,
|
|
485
|
+
"content": "Test",
|
|
486
|
+
"blocked": false,
|
|
487
|
+
"children": [
|
|
488
|
+
{
|
|
489
|
+
"id": 6,
|
|
490
|
+
"content": "Text to search for"
|
|
491
|
+
},
|
|
492
|
+
// ...
|
|
493
|
+
],
|
|
494
|
+
"threadOf": null,
|
|
495
|
+
"author": {
|
|
496
|
+
"id": "123456",
|
|
497
|
+
"name": "Joe Doe"
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
// ...
|
|
501
|
+
]
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### Post a Comment
|
|
507
|
+
|
|
508
|
+
*REST API equivalent: [Public REST API -> Post a Comment](#post-a-comment)*
|
|
509
|
+
|
|
510
|
+
**Example request**
|
|
511
|
+
|
|
512
|
+
```graphql
|
|
513
|
+
mutation createComment {
|
|
514
|
+
createComment(
|
|
515
|
+
input: {
|
|
516
|
+
relation: "api::page.page:1"
|
|
517
|
+
content: "Hello World!"
|
|
518
|
+
threadOf: 3
|
|
519
|
+
author: { id: "12345678", name: "John Wick", email: "test@test.pl" }
|
|
520
|
+
}
|
|
521
|
+
) {
|
|
522
|
+
id
|
|
523
|
+
content
|
|
524
|
+
threadOf {
|
|
525
|
+
id
|
|
526
|
+
}
|
|
527
|
+
author {
|
|
528
|
+
id
|
|
529
|
+
name
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
**Example response**
|
|
536
|
+
|
|
537
|
+
```json
|
|
538
|
+
{
|
|
539
|
+
"data": {
|
|
540
|
+
"createComment": {
|
|
541
|
+
"id": 34,
|
|
542
|
+
"content": "Hello World!",
|
|
543
|
+
"threadOf": {
|
|
544
|
+
"id": 3
|
|
545
|
+
},
|
|
546
|
+
"author": {
|
|
547
|
+
"id": "12345678",
|
|
548
|
+
"name": "John Wick"
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### Update Comment
|
|
556
|
+
|
|
557
|
+
*REST API equivalent: [Public REST API -> Update Comment](#update-comment)*
|
|
558
|
+
|
|
559
|
+
**Example request**
|
|
560
|
+
|
|
561
|
+
```graphql
|
|
562
|
+
mutation updateComment {
|
|
563
|
+
updateComment(
|
|
564
|
+
input: {
|
|
565
|
+
id: 34
|
|
566
|
+
relation: "api::page.page:1"
|
|
567
|
+
content: "I've changed it!"
|
|
568
|
+
author: { id: "12345678" }
|
|
569
|
+
}
|
|
570
|
+
) {
|
|
571
|
+
id
|
|
572
|
+
content
|
|
573
|
+
threadOf {
|
|
574
|
+
id
|
|
575
|
+
}
|
|
576
|
+
author {
|
|
577
|
+
id
|
|
578
|
+
name
|
|
579
|
+
}
|
|
580
|
+
createdAt
|
|
581
|
+
updatedAt
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
**Example response**
|
|
587
|
+
|
|
588
|
+
```json
|
|
589
|
+
{
|
|
590
|
+
"data": {
|
|
591
|
+
"updateComment": {
|
|
592
|
+
"id": 34,
|
|
593
|
+
"content": "I've changed it!",
|
|
594
|
+
"threadOf": {
|
|
595
|
+
"id": 3
|
|
596
|
+
},
|
|
597
|
+
"author": {
|
|
598
|
+
"id": "12345678",
|
|
599
|
+
"name": "John Wick"
|
|
600
|
+
},
|
|
601
|
+
"createdAt": "2022-01-26T07:45:35.978Z",
|
|
602
|
+
"updatedAt": "2022-01-26T07:47:44.659Z"
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
### Delete Comment
|
|
609
|
+
|
|
610
|
+
*REST API equivalent: [Public REST API -> Delete Comment](#delete-comment)*
|
|
611
|
+
|
|
612
|
+
**Example request**
|
|
613
|
+
|
|
614
|
+
```graphql
|
|
615
|
+
mutation removeComment {
|
|
616
|
+
removeComment(
|
|
617
|
+
input: { id: 33, relation: "api::page.page:1", author: { id: "12345678" } }
|
|
618
|
+
) {
|
|
619
|
+
id
|
|
620
|
+
removed
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
**Example response**
|
|
626
|
+
|
|
627
|
+
```json
|
|
628
|
+
{
|
|
629
|
+
"data": {
|
|
630
|
+
"removeComment": {
|
|
631
|
+
"id": 33,
|
|
632
|
+
"removed": true
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
### Issue Abuse Report against specified Comment
|
|
639
|
+
|
|
640
|
+
*REST API equivalent: [Public REST API -> Issue Abuse Report against specified Comment](#issue-abuse-report-against-specified-comment)*
|
|
641
|
+
|
|
642
|
+
**Example request body**
|
|
643
|
+
|
|
644
|
+
```graphql
|
|
645
|
+
mutation createAbuseReport {
|
|
646
|
+
createAbuseReport(
|
|
647
|
+
input: {
|
|
648
|
+
commentId: 34
|
|
649
|
+
relation: "api::page.page:1"
|
|
650
|
+
reason: BAD_LANGUAGE
|
|
651
|
+
content: "Rude language"
|
|
652
|
+
}
|
|
653
|
+
) {
|
|
654
|
+
id
|
|
655
|
+
reason
|
|
656
|
+
content
|
|
657
|
+
related {
|
|
658
|
+
id
|
|
659
|
+
author {
|
|
660
|
+
id
|
|
661
|
+
name
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
*Available reason enums:* `BAD_WORDS`, `OTHER`, `DISCRIMINATION` (want more? See [configuration section](#configuration).)
|
|
669
|
+
|
|
670
|
+
**Example response**
|
|
671
|
+
|
|
672
|
+
```json
|
|
673
|
+
{
|
|
674
|
+
"data": {
|
|
675
|
+
"createAbuseReport": {
|
|
676
|
+
"id": 28,
|
|
677
|
+
"content": "Rude language",
|
|
678
|
+
"reason": "DISCRIMINATION",
|
|
679
|
+
"related": {
|
|
680
|
+
"id": 34,
|
|
681
|
+
"author": {
|
|
682
|
+
"id": "12345678",
|
|
683
|
+
"name": "John Wick"
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
## 🧩 Examples
|
|
343
692
|
|
|
344
|
-
Live example of plugin usage can be found in the [VirtusLab Strapi Examples](https://github.com/VirtusLab/strapi-examples/tree/master/strapi-plugin-comments) repository.
|
|
693
|
+
Live example of plugin usage can be found in the [VirtusLab Strapi Examples](https://github.com/VirtusLab/strapi-examples/tree/master/strapi-v4-plugin-comments) repository.
|
|
345
694
|
|
|
346
|
-
## Contributing
|
|
695
|
+
## 🤝 Contributing
|
|
347
696
|
|
|
348
697
|
Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!
|
|
349
698
|
|
|
350
|
-
## Community support
|
|
699
|
+
## 👨💻 Community support
|
|
351
700
|
|
|
352
701
|
For general help using Strapi, please refer to [the official Strapi documentation](https://strapi.io/documentation/). For additional help, you can use one of these channels to ask a question:
|
|
353
702
|
|
|
@@ -355,6 +704,6 @@ For general help using Strapi, please refer to [the official Strapi documentatio
|
|
|
355
704
|
- [Slack - VirtusLab Open Source](https://virtuslab-oss.slack.com) We're present on a public channel #strapi-molecules
|
|
356
705
|
- [GitHub](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/issues) (Bug reports, Contributions, Questions and Discussions)
|
|
357
706
|
|
|
358
|
-
## License
|
|
707
|
+
## 📝 License
|
|
359
708
|
|
|
360
709
|
[MIT License](LICENSE.md) Copyright (c) [VirtusLab Sp. z o.o.](https://virtuslab.com/) & [Strapi Solutions](https://strapi.io/).
|