strapi-plugin-comments 2.0.0-beta.6 → 2.0.0

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.
Files changed (71) hide show
  1. package/.circleci/config.yml +1 -1
  2. package/README.md +474 -119
  3. package/__mocks__/initSetup.js +53 -0
  4. package/admin/src/components/ActionButton/styles.js +10 -0
  5. package/admin/src/components/DiscussionThread/index.js +3 -7
  6. package/admin/src/components/DiscussionThreadItem/index.js +25 -74
  7. package/admin/src/components/DiscussionThreadItem/styles.js +4 -79
  8. package/admin/src/components/DiscussionThreadItemActions/index.js +82 -40
  9. package/admin/src/components/DiscussionThreadItemActions/styles.js +1 -12
  10. package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +2 -3
  11. package/admin/src/components/DiscussionThreadItemFooter/index.js +47 -0
  12. package/admin/src/components/DiscussionThreadItemFooter/styles.js +13 -0
  13. package/admin/src/components/DiscussionThreadItemReviewAction/index.js +131 -0
  14. package/admin/src/components/IconButton/styles.js +14 -0
  15. package/admin/src/components/ReportsReviewModal/index.js +1 -1
  16. package/admin/src/components/ReportsReviewTable/index.js +12 -6
  17. package/admin/src/components/StatusBadge/index.js +17 -0
  18. package/admin/src/components/StatusBadge/styles.js +17 -0
  19. package/admin/src/pages/Details/components/DetailsEntity/index.js +40 -24
  20. package/admin/src/pages/Details/components/DetailsFilters/index.js +8 -10
  21. package/admin/src/pages/Details/index.js +9 -15
  22. package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +36 -66
  23. package/admin/src/pages/Discover/index.js +4 -1
  24. package/admin/src/translations/en.json +14 -15
  25. package/admin/src/utils/index.js +2 -0
  26. package/admin/src/utils/renderInitials.js +5 -0
  27. package/admin/src/utils/resolveCommentStatus.js +4 -4
  28. package/content-types/comment.js +0 -4
  29. package/package.json +8 -4
  30. package/public/assets/logo.png +0 -0
  31. package/public/assets/preview.png +0 -0
  32. package/server/config/index.js +5 -0
  33. package/server/controllers/client.js +11 -21
  34. package/server/controllers/utils/__tests__/functions.test.js +2 -2
  35. package/server/controllers/utils/parsers.js +19 -0
  36. package/server/graphql/index.js +26 -0
  37. package/server/graphql/mutations/createAbuseReport.js +25 -0
  38. package/server/graphql/mutations/createComment.js +25 -0
  39. package/server/graphql/mutations/index.js +21 -0
  40. package/server/graphql/mutations/removeComment.js +25 -0
  41. package/server/graphql/mutations/updateComment.js +25 -0
  42. package/server/graphql/queries/findAllFlat.js +29 -0
  43. package/server/graphql/queries/findAllInHierarchy.js +31 -0
  44. package/server/graphql/queries/index.js +19 -0
  45. package/server/graphql/resolvers-config.js +15 -0
  46. package/server/graphql/types/comment-author.js +9 -0
  47. package/server/graphql/types/comment-nested.js +16 -0
  48. package/server/graphql/types/comment.js +15 -0
  49. package/server/graphql/types/create-comment-author.js +9 -0
  50. package/server/graphql/types/create-comment.js +9 -0
  51. package/server/graphql/types/create-report.js +9 -0
  52. package/server/graphql/types/id.js +24 -0
  53. package/server/graphql/types/identify-comment-author.js +6 -0
  54. package/server/graphql/types/index.js +16 -0
  55. package/server/graphql/types/remove-comment.js +8 -0
  56. package/server/graphql/types/report-reason.js +10 -0
  57. package/server/graphql/types/report.js +11 -0
  58. package/server/graphql/types/update-comment.js +9 -0
  59. package/server/register.js +3 -1
  60. package/server/services/__tests__/common.test.js +165 -0
  61. package/server/services/admin.js +18 -15
  62. package/server/services/client.js +73 -51
  63. package/server/services/common.js +42 -14
  64. package/server/services/graphql.js +190 -0
  65. package/server/services/index.js +2 -0
  66. package/server/services/utils/__tests__/functions.test.js +9 -73
  67. package/server/services/utils/functions.js +30 -27
  68. package/server/utils/__tests__/functions.test.js +17 -0
  69. package/admin/src/components/DiscussionThreadItemMeta/index.js +0 -31
  70. package/admin/src/components/DiscussionThreadItemWarnings/index.js +0 -147
  71. package/admin/src/components/DiscussionThreadItemWarnings/styles.js +0 -7
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
- # Strapi v4 - Comments plugin - BETA
2
-
3
- <p align="center">
1
+ <div align="center" width="150px">
2
+ <img style="width: 150px; height: auto;" src="public/assets/logo.png" alt="Logo - Strapi Comments plugin" />
3
+ </div>
4
+ <div align="center">
5
+ <h1>Strapi v4 - Comments plugin</h1>
6
+ <p>Powerful Strapi based comments moderation tool for you and your users</p>
4
7
  <a href="https://www.npmjs.org/package/strapi-plugin-comments">
5
- <img src="https://img.shields.io/npm/v/strapi-plugin-comments/latest.svg" alt="NPM Version" />
8
+ <img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/VirtusLab-Open-Source/strapi-plugin-comments?label=npm&logo=npm">
6
9
  </a>
7
10
  <a href="https://www.npmjs.org/package/strapi-plugin-comments">
8
11
  <img src="https://img.shields.io/npm/dm/strapi-plugin-comments.svg" alt="Monthly download on NPM" />
@@ -13,15 +16,38 @@
13
16
  <a href="https://codecov.io/gh/VirtusLab-Open-Source/strapi-plugin-comments">
14
17
  <img src="https://codecov.io/gh/VirtusLab-Open-Source/strapi-plugin-comments/coverage.svg?branch=master" alt="codecov.io" />
15
18
  </a>
16
- </p>
19
+ <a href="https://sharing.clickup.com/tl/xhcmx-83/strapiv-4-comments-roadmap">
20
+ <img src="https://img.shields.io/website?down_message=roadmap&label=product&up_message=roadmap&url=https%3A%2F%2Fsharing.clickup.com%2Ftl%2Fxhcmx-83%2Fstrapiv-4-comments-roadmap" />
21
+ </a>
22
+ <a href="https://sharing.clickup.com/b/xhcmx-63/strapiv-4-comments-board">
23
+ <img src="https://img.shields.io/website?down_message=board&label=product&up_color=blue&up_message=board&url=https%3A%2F%2Fsharing.clickup.com%2Fb%2Fxhcmx-63%2Fstrapiv-4-comments-board" />
24
+ </a>
25
+ </div>
26
+
27
+ ---
28
+
29
+ <div style="margin: 20px 0" align="center">
30
+ <img style="width: 100%; height: auto;" src="public/assets/preview.png" alt="UI preview" />
31
+ </div>
32
+
17
33
 
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.
34
+ 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.
19
35
 
20
- ### Versions
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)
36
+ ## ✨ Features
23
37
 
24
- ### ⏳ Installation
38
+ - **Comments Public REST + GraphQL API:** Elegant, entirely customizable and a fully extensible admin panel.
39
+ - **Strapi &amp; generic users:** Support for built-in &amp; also generic non-Strapi users that might be the comments authors.
40
+ - **Any Content Type relation:** Comments can by linked to any of your Content Types by default. Simply, you're controlling it.
41
+ - **Moderation Panel:** Search & Filter through the bucket with your auditory comments. Manage them by blocking single ones or full threads. All in combined list &amp; hierarchical tree view of threads.
42
+ - **Automated Bad Words filtering:** By detault end users are not allowed to post abusing comments where bad words have been used.
43
+ - **Abuse Reporting & Reviewing:** Don't allow inferior language, react to reports from your community, send email notifiactions about abuse reports
44
+
45
+ ## ⚙️ Versions
46
+
47
+ - **Strapi v4** - (current) - [v2.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments)
48
+ - **Strapi v3** - [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/tree/strapi-v3)
49
+
50
+ ## ⏳ Installation
25
51
 
26
52
  (Use **yarn** to install this plugin within your Strapi project (recommended). [Install yarn with these docs](https://yarnpkg.com/lang/en/docs/install/).)
27
53
 
@@ -46,7 +72,7 @@ The **Comments** plugin should appear in the **Plugins** section of Strapi sideb
46
72
 
47
73
  Enjoy 🎉
48
74
 
49
- ### 🖐 Requirements
75
+ ## 🖐 Requirements
50
76
 
51
77
  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
78
 
@@ -58,38 +84,37 @@ In our minimum support we're following [official Node.js releases timelines](htt
58
84
 
59
85
  **Supported Strapi versions**:
60
86
 
61
- - Strapi v4.0.5 (recently tested)
87
+ - Strapi v4.0.7 (recently tested)
62
88
  - Strapi v4.x
63
89
 
64
- (This plugin is not working with v3.x and not may work with the older Strapi v4 versions, but these are not tested nor officially supported at this time.)
90
+ > 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).
65
91
 
66
92
  **We recommend always using the latest version of Strapi to start your new projects**.
67
93
 
68
- ## Features
69
-
70
- - **Comments Public API:** Elegant, entirely customizable and a fully extensible admin panel.
71
- - **Strapi &amp; generic users:** Support for built-in &amp; also generic non-Strapi users that might be the comments authors.
72
- - **Any Content Type relation:** Comments can by linked to any of your Content Types by default. Simply, you're controlling it.
73
- - **Moderation Panel:** Search & Filter through the bucket with your auditory comments. Manage them by blocking single ones or full threads. All in combined list &amp; hierarchical tree view of threads.
74
- - **Automated Bad Words filtering:** By detault end users are not allowed to post abusing comments where bad words have been used.
75
- - **Abuse Reporting & Reviewing:** Don't allow inferior language, react to reports from your community, send email notifiactions about abuse reports
76
-
77
- ## Configuration
94
+ ## 🔧 Configuration
78
95
  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.
79
96
 
80
97
 
81
98
  ```js
82
- ...
83
- comments: {
84
- badWords: false,
85
- moderatorRoles: ["Authenticated"],
86
- approvalFlow: ['api::page.page'],
87
- entryLabel: {
88
- '*': ['Title', 'title', 'Name', 'name', 'Subject', 'subject'],
89
- 'api::page.page': ['MyField'],
99
+ module.exports = ({ env }) => ({
100
+ //...
101
+ comments: {
102
+ badWords: false,
103
+ moderatorRoles: ["Authenticated"],
104
+ approvalFlow: ['api::page.page'],
105
+ entryLabel: {
106
+ '*': ['Title', 'title', 'Name', 'name', 'Subject', 'subject'],
107
+ 'api::page.page': ['MyField'],
108
+ },
109
+ reportReasons: {
110
+ 'MY_CUSTOM_REASON': 'MY_CUSTOM_REASON',
111
+ },
112
+ gql: {
113
+ // ...
114
+ },
90
115
  },
91
- },
92
- ...
116
+ //...
117
+ });
93
118
  ```
94
119
 
95
120
  ### Properties
@@ -97,12 +122,38 @@ To setup amend default plugin configuration we recommend to put following snippe
97
122
  - `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.
98
123
  - `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.
99
124
  - `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 `*`.
125
+ - `reportReasons` - set of enums you would like to use for issuing abuse reports. Provided by default `'BAD_LANGUAGE'`, `'DISCRIMINATION'` and `'OTHER'`.
126
+ - `gql` - specific configuration for GraphQL. See [Additional GQL Configuration](#additional-gql-configuration)
100
127
 
101
128
  ## Additional GQL Configuration
129
+ 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)** and decide if you would like to call it by anyone (open for world) or only by authenticated users (Strapi users).
130
+
131
+ ```json
132
+ {
133
+ // ...
134
+ gql: {
135
+ auth: true, // Default: false
136
+ },
137
+ // ...
138
+ }
139
+ ```
140
+
141
+ ### Properties
142
+ - `auth` - does GraphQL Queries should be authenticated or not? Default: `false`
102
143
 
103
- > To be done
144
+ ### Queries
104
145
 
105
- ## RBAC
146
+ See [available GQL specification section](#public-graphql-specification).
147
+
148
+ > If `auth` is set to `true` you must provide relevant authentication headers to all requests like for example:
149
+ >
150
+ > ```json
151
+ > {
152
+ > "Authorization": "Bearer <your token here>"
153
+ > }
154
+ > ```
155
+
156
+ ## 👤 RBAC
106
157
  Plugin provides granular permissions based on Strapi RBAC functionality.
107
158
 
108
159
  ### Mandatory permissions
@@ -116,9 +167,8 @@ Feature / Capability focused permissions:
116
167
  - _Plugins_ -> _Comments_ -> _Reports: Read_ - allows you to see the list of issued abuse reports against comments
117
168
  - _Plugins_ -> _Comments_ -> _Reports: Moderate_ - allows you to review (resolve) issued abuse reports against comments
118
169
 
119
- ## Public API Comment model
170
+ ## Base Comment model
120
171
 
121
- ### Generic (non Strapi User)
122
172
  ```json
123
173
  {
124
174
  "id": 1,
@@ -127,52 +177,31 @@ Feature / Capability focused permissions:
127
177
  "blockedThread": true,
128
178
  "blockReason": null,
129
179
  "authorUser": null,
130
- "authorId": "207ccfdc-94ba-45eb-979c-790f6f49c392",
131
- "authorName": "Joe Doe",
132
- "authorEmail": "jdoe@sample.com",
133
- "authorAvatar": null,
134
- "createdAt": "2020-07-14T20:13:01.649Z",
135
- "updatedAt": "2020-07-14T20:13:01.670Z",
136
- "related": {}, // Related content type entity
137
- "reports": [] // Reports issued against this comment
138
- }
139
- ```
140
- ### Strapi User
141
- ```json
142
- {
143
- "id": 1,
144
- "content": "My comment content",
145
- "blocked": true,
146
- "blockedThread": null,
147
- "blockReason": null,
148
- "authorUser": {
149
- "id": 1,
150
- "username": "Sample User",
151
- "email": "user@sample.com",
152
- "provider": "local",
153
- "confirmed": true,
154
- "blocked": false,
155
- "role": 1,
156
- "created_at": "2020-07-10T08:38:03.157Z",
157
- "updated_at": "2020-07-10T08:38:03.170Z"
180
+ "removed": null,
181
+ "approvalStatus": "APPROVED", // Only in case of enabled approval flow. Default: null
182
+ "author": {
183
+ "id": "207ccfdc-94ba-45eb-979c-790f6f49c392", // For Strapi users id reflects to the format used by your Strapi
184
+ "name": "Joe Doe", // For Strapi users it is equal to 'username' field
185
+ "email": "jdoe@sample.com",
186
+ "avatar": null,
158
187
  },
159
- "authorId": null,
160
- "authorName": null,
161
- "authorEmail": null,
162
- "authorAvatar": null,
163
188
  "createdAt": "2020-07-14T20:13:01.649Z",
164
189
  "updatedAt": "2020-07-14T20:13:01.670Z",
165
190
  "related": {}, // Related content type entity
166
191
  "reports": [] // Reports issued against this comment
167
192
  }
168
-
169
193
  ```
170
194
 
171
- ## Public API specification
195
+ ## 🕸️ Public REST API specification
196
+
197
+ **Strapi Users vs. Generic authors**
198
+ > Keep in mind that if you're using auth / authz your requests to setup proper user contexts it has got higher priority in order to take author data comparing to `author` property provided as part of your payload.
172
199
 
173
200
  ### Get Comments
174
201
 
175
- `GET <host>/comments/api::<collection name>.<content type name>:<entity id>`
202
+ *GraphQL equivalent: [Public GraphQL API -> Get Comments](#get-comments-1)*
203
+
204
+ `GET <host>/api/comments/api::<collection name>.<content type name>:<entity id>`
176
205
 
177
206
  Return a hierarchical tree structure of comments for specified instance of Content Type like for example `Page` with `ID: 1`
178
207
 
@@ -180,25 +209,29 @@ Return a hierarchical tree structure of comments for specified instance of Conte
180
209
 
181
210
  **Example response body**
182
211
 
183
- ```
212
+ ```json
184
213
  [
185
214
  {
186
- -- Comment Model fields ---,
215
+ // -- Comment Model fields ---,
187
216
  children: [
188
217
  {
189
- -- Comment Model fields ---,
190
- children: [...]
218
+ // -- Comment Model fields ---,
219
+ children: [
220
+ // ...
221
+ ]
191
222
  },
192
- ...
223
+ // ...
193
224
  ]
194
225
  },
195
- ...
226
+ // ...
196
227
  ]
197
228
  ```
198
229
 
199
230
  ### Get Comments (flat structure)
200
231
 
201
- `GET <host>/comments/api::<collection name>.<content type name>:<entity id>/flat`
232
+ *GraphQL equivalent: [Public GraphQL API -> Get Comments (flat structure)](#get-comments-flat-structure-1)*
233
+
234
+ `GET <host>/api/comments/api::<collection name>.<content type name>:<entity id>/flat`
202
235
 
203
236
  Return a flat structure of comments for specified instance of Content Type like for example `Page` with `ID: 1`
204
237
 
@@ -206,15 +239,15 @@ Return a flat structure of comments for specified instance of Content Type like
206
239
 
207
240
  **Example response body**
208
241
 
209
- ```
242
+ ```json
210
243
  [
211
244
  {
212
- -- Comment Model fields ---
245
+ // -- Comment Model fields ---
213
246
  },
214
247
  {
215
- -- Comment Model fields ---
248
+ // -- Comment Model fields ---
216
249
  },
217
- ...
250
+ // ...
218
251
  ]
219
252
  ```
220
253
 
@@ -224,7 +257,9 @@ Return a flat structure of comments for specified instance of Content Type like
224
257
 
225
258
  ### Post a Comment
226
259
 
227
- `POST <host>/comments/api::<collection name>.<content type name>:<entity id>`
260
+ *GraphQL equivalent: [Public GraphQL API -> Post a Comments](#post-a-comment-1)*
261
+
262
+ `POST <host>/api/comments/api::<collection name>.<content type name>:<entity id>`
228
263
 
229
264
  Posts a Comment related to specified instance of Content Type like for example `Page` with `ID: 1`
230
265
 
@@ -233,23 +268,25 @@ Posts a Comment related to specified instance of Content Type like for example `
233
268
  **Example request body**
234
269
 
235
270
  *Generic (non Strapi User)*
236
- ```
271
+ ```json
237
272
  {
238
- "author": {
239
- "id": "<any ID like value>",
240
- "name": "Joe Doe",
241
- "email": "jdoe@sample.com",
242
- "avatar": "<any image url>"
243
- },
273
+ "author": {
274
+ "id": "<any ID like value>",
275
+ "name": "Joe Doe",
276
+ "email": "jdoe@sample.com",
277
+ "avatar": "<any image url>"
278
+ },
244
279
  "content": "My sample response",
245
280
  "threadOf": 2, // id of comment we would like to start / continue the thread (Optional)
246
281
  }
247
282
  ```
248
283
 
249
284
  *Strapi user*
250
- ```
285
+
286
+ > Author is taken directly from the request context
287
+
288
+ ```json
251
289
  {
252
- "authorUser": 1, // id of a author user. Optional in case of 'enableUsers: true' in the plugin configuration
253
290
  "content": "My sample response",
254
291
  "threadOf": 2, // id of comment we would like to start / continue the thread (Optional)
255
292
  }
@@ -257,9 +294,9 @@ Posts a Comment related to specified instance of Content Type like for example `
257
294
 
258
295
  **Example response body**
259
296
 
260
- ```
297
+ ```json
261
298
  {
262
- -- Comment Model fields ---
299
+ // -- Comment Model fields ---
263
300
  }
264
301
  ```
265
302
 
@@ -269,7 +306,9 @@ Posts a Comment related to specified instance of Content Type like for example `
269
306
 
270
307
  ### Update Comment
271
308
 
272
- `PUT <host>/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>`
309
+ *GraphQL equivalent: [Public GraphQL API -> Update Comments](#update-comment-1)*
310
+
311
+ `PUT <host>/api/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>`
273
312
 
274
313
  Updates a specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1`
275
314
 
@@ -278,28 +317,30 @@ Updates a specified Comment content based on it `commentId` and related to speci
278
317
  **Example request body**
279
318
 
280
319
  *Generic (non Strapi User)*
281
- ```
320
+ ```json
282
321
  {
283
- "author": {
284
- "id": "<any ID like value>"
285
- },
322
+ "author": {
323
+ "id": "<any ID like value>"
324
+ },
286
325
  "content": "My sample response"
287
326
  }
288
327
  ```
289
328
 
290
329
  *Strapi user*
291
- ```
330
+
331
+ > Author is taken directly from the request context
332
+
333
+ ```json
292
334
  {
293
- "authorUser": 1, // id of a author user. Optional in case of 'enableUsers: true' in the plugin configuration
294
335
  "content": "My sample response"
295
336
  }
296
337
  ```
297
338
 
298
339
  **Example response body**
299
340
 
300
- ```
341
+ ```json
301
342
  {
302
- -- Comment Model fields ---
343
+ // -- Comment Model fields ---
303
344
  }
304
345
  ```
305
346
 
@@ -310,7 +351,9 @@ Updates a specified Comment content based on it `commentId` and related to speci
310
351
 
311
352
  ### Delete Comment
312
353
 
313
- `DELETE <host>/comments/api::<collection name>.<content type name>:<entity id>/<commentId>?authorId=<authorId>`
354
+ *GraphQL equivalent: [Public GraphQL API -> Delete Comment](#delete-comment-1)*
355
+
356
+ `DELETE <host>/api/comments/api::<collection name>.<content type name>:<entity id>/<commentId>?authorId=<authorId>`
314
357
 
315
358
  Deletes a specified Comment based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1`.
316
359
 
@@ -318,9 +361,9 @@ Deletes a specified Comment based on it `commentId` and related to specified ins
318
361
 
319
362
  **Example response body**
320
363
 
321
- ```
364
+ ```json
322
365
  {
323
- -- Empty Response ---
366
+ // -- Empty Response ---
324
367
  }
325
368
  ```
326
369
 
@@ -329,9 +372,11 @@ Deletes a specified Comment based on it `commentId` and related to specified ins
329
372
  - `409` - Conflict. Occurs when trying to delete a non existing comment.
330
373
 
331
374
 
332
- ### Report abuse in the Comment
375
+ ### Issue Abuse Report against specified Comment
333
376
 
334
- `POST <host>/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>/report-abuse`
377
+ *GraphQL equivalent: [Public GraphQL API -> Issue Abuse Report against specified Comment](#issue-abuse-report-against-specified-comment-1)*
378
+
379
+ `POST <host>/api/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>/report-abuse`
335
380
 
336
381
  Reports abuse in specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1` and requests moderator attention.
337
382
 
@@ -339,20 +384,20 @@ Reports abuse in specified Comment content based on it `commentId` and related t
339
384
 
340
385
  **Example request body**
341
386
 
342
- ```
387
+ ```json
343
388
  {
344
389
  "reason": "<reason enum>",
345
390
  "content": "This comment is not relevant"
346
391
  }
347
392
  ```
348
393
 
349
- *Available reason enums:* `OTHER`, `BAD_WORDS`, `DISCRIMINATION`
394
+ *Available reason enums:* `BAD_WORDS`, `OTHER`, `DISCRIMINATION` (want more? See [configuration section](#configuration).)
350
395
 
351
396
  **Example response body**
352
397
 
353
- ```
398
+ ```json
354
399
  {
355
- -- Comment Abuse Report fields ---
400
+ // -- Comment Abuse Report fields ---
356
401
  }
357
402
  ```
358
403
 
@@ -360,22 +405,332 @@ Reports abuse in specified Comment content based on it `commentId` and related t
360
405
  - `200` - Successful. Response with reported abuse.
361
406
  - `409` - Conflict. Occurs when trying to report an abuse to a non existing comment.
362
407
 
363
- ## Examples
408
+ ## 🕸️ Public GraphQL specification
409
+
410
+ **Strapi Users vs. Generic authors**
411
+ > Keep in mind that if you're using auth / authz your requests to setup proper user contexts it has got higher priority in order to take author data comparing to `author` property provided as part of your payload.
412
+
413
+ **Testing**
414
+ > To test all queries and understand the schemas use GraphQL Playground exposed by `@strapi/plugin-graphql` on `http://localhost:1337/graphql`
415
+
416
+ ### Get Comments
417
+
418
+ *REST API equivalent: [Public REST API -> Get Comments](#get-comments)*
419
+
420
+ **Example request**
421
+
422
+ ```graphql
423
+ query {
424
+ findAllFlat(
425
+ relation: "api::page.page:1"
426
+ filters: { content: { contains: "Test" } }
427
+ ) {
428
+ id
429
+ content
430
+ blocked
431
+ threadOf {
432
+ id
433
+ }
434
+ author {
435
+ id
436
+ name
437
+ }
438
+ }
439
+ }
440
+ ```
441
+
442
+ **Example response**
443
+
444
+ ```json
445
+ {
446
+ "data": {
447
+ "findAllFlat": [
448
+ {
449
+ "id": 3,
450
+ "content": "Test",
451
+ "blocked": false,
452
+ "threadOf": null,
453
+ "author": {
454
+ "id": "123456",
455
+ "name": "Joe Doe"
456
+ }
457
+ },
458
+ // ...
459
+ ]
460
+ }
461
+ ```
462
+
463
+ ### Get Comments (flat structure)
464
+
465
+ *REST API equivalent: [Public REST API -> Get Comments (flat structure)](#get-comments-flat-structure)*
466
+
467
+ **Example request**
468
+
469
+ ```graphql
470
+ query {
471
+ findAllInHierarchy(relation: "api::page.page:1") {
472
+ id
473
+ content
474
+ blocked
475
+ children {
476
+ id
477
+ content
478
+ }
479
+ threadOf {
480
+ id
481
+ }
482
+ author {
483
+ id
484
+ name
485
+ }
486
+ }
487
+ }
488
+ ```
489
+
490
+ **Example response**
491
+
492
+ ```json
493
+ {
494
+ "data": {
495
+ "findAllInHierarchy": [
496
+ {
497
+ "id": 1,
498
+ "content": "Test",
499
+ "blocked": false,
500
+ "children": [
501
+ {
502
+ "id": 6,
503
+ "content": "Text to search for"
504
+ },
505
+ // ...
506
+ ],
507
+ "threadOf": null,
508
+ "author": {
509
+ "id": "123456",
510
+ "name": "Joe Doe"
511
+ }
512
+ },
513
+ // ...
514
+ ]
515
+ }
516
+ }
517
+ ```
518
+
519
+ ### Post a Comment
520
+
521
+ *REST API equivalent: [Public REST API -> Post a Comment](#post-a-comment)*
522
+
523
+ **Example request**
524
+
525
+ ```graphql
526
+ mutation createComment {
527
+ createComment(
528
+ input: {
529
+ relation: "api::page.page:1"
530
+ content: "Hello World!"
531
+ threadOf: 3
532
+ author: { id: "12345678", name: "John Wick", email: "test@test.pl" } # Optional if using auth / authz requests
533
+ }
534
+ ) {
535
+ id
536
+ content
537
+ threadOf {
538
+ id
539
+ }
540
+ author {
541
+ id
542
+ name
543
+ }
544
+ }
545
+ }
546
+ ```
547
+
548
+ **Example response**
549
+
550
+ ```json
551
+ {
552
+ "data": {
553
+ "createComment": {
554
+ "id": 34,
555
+ "content": "Hello World!",
556
+ "threadOf": {
557
+ "id": 3
558
+ },
559
+ "author": {
560
+ "id": "12345678",
561
+ "name": "John Wick"
562
+ }
563
+ }
564
+ }
565
+ }
566
+ ```
567
+
568
+ ### Update Comment
569
+
570
+ *REST API equivalent: [Public REST API -> Update Comment](#update-comment)*
571
+
572
+ **Example request**
573
+
574
+ ```graphql
575
+ mutation updateComment {
576
+ updateComment(
577
+ input: {
578
+ id: 34
579
+ relation: "api::page.page:1"
580
+ content: "I've changed it!"
581
+ author: { id: "12345678" } # Optional if using auth / authz requests
582
+ }
583
+ ) {
584
+ id
585
+ content
586
+ threadOf {
587
+ id
588
+ }
589
+ author {
590
+ id
591
+ name
592
+ }
593
+ createdAt
594
+ updatedAt
595
+ }
596
+ }
597
+ ```
364
598
 
365
- 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.
599
+ **Example response**
600
+
601
+ ```json
602
+ {
603
+ "data": {
604
+ "updateComment": {
605
+ "id": 34,
606
+ "content": "I've changed it!",
607
+ "threadOf": {
608
+ "id": 3
609
+ },
610
+ "author": {
611
+ "id": "12345678",
612
+ "name": "John Wick"
613
+ },
614
+ "createdAt": "2022-01-26T07:45:35.978Z",
615
+ "updatedAt": "2022-01-26T07:47:44.659Z"
616
+ }
617
+ }
618
+ }
619
+ ```
366
620
 
367
- ## Contributing
621
+ ### Delete Comment
622
+
623
+ *REST API equivalent: [Public REST API -> Delete Comment](#delete-comment)*
624
+
625
+ **Example request**
626
+
627
+ ```graphql
628
+ mutation removeComment {
629
+ removeComment(
630
+ input: {
631
+ id: 33,
632
+ relation: "api::page.page:1",
633
+ author: { id: "12345678" } # Optional if using auth / authz requests
634
+ }
635
+ ) {
636
+ id
637
+ removed
638
+ }
639
+ }
640
+ ```
641
+
642
+ **Example response**
643
+
644
+ ```json
645
+ {
646
+ "data": {
647
+ "removeComment": {
648
+ "id": 33,
649
+ "removed": true
650
+ }
651
+ }
652
+ }
653
+ ```
654
+
655
+ ### Issue Abuse Report against specified Comment
656
+
657
+ *REST API equivalent: [Public REST API -> Issue Abuse Report against specified Comment](#issue-abuse-report-against-specified-comment)*
658
+
659
+ **Example request body**
660
+
661
+ ```graphql
662
+ mutation createAbuseReport {
663
+ createAbuseReport(
664
+ input: {
665
+ commentId: 34
666
+ relation: "api::page.page:1"
667
+ reason: BAD_LANGUAGE
668
+ content: "Rude language"
669
+ }
670
+ ) {
671
+ id
672
+ reason
673
+ content
674
+ related {
675
+ id
676
+ author {
677
+ id
678
+ name
679
+ }
680
+ }
681
+ }
682
+ }
683
+ ```
684
+
685
+ *Available reason enums:* `BAD_WORDS`, `OTHER`, `DISCRIMINATION` (want more? See [configuration section](#configuration).)
686
+
687
+ **Example response**
688
+
689
+ ```json
690
+ {
691
+ "data": {
692
+ "createAbuseReport": {
693
+ "id": 28,
694
+ "content": "Rude language",
695
+ "reason": "DISCRIMINATION",
696
+ "related": {
697
+ "id": 34,
698
+ "author": {
699
+ "id": "12345678",
700
+ "name": "John Wick"
701
+ }
702
+ }
703
+ }
704
+ }
705
+ }
706
+ ```
707
+
708
+ ## 🧩 Examples
709
+
710
+ 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.
711
+
712
+ ## 🤝 Contributing
713
+
714
+ <div>
715
+ <a href="https://sharing.clickup.com/tl/xhcmx-83/strapiv-4-comments-roadmap">
716
+ <img src="https://img.shields.io/website?down_message=roadmap&label=product&up_message=roadmap&url=https%3A%2F%2Fsharing.clickup.com%2Ftl%2Fxhcmx-83%2Fstrapiv-4-comments-roadmap" />
717
+ </a>
718
+ <a href="https://sharing.clickup.com/b/xhcmx-63/strapiv-4-comments-board">
719
+ <img src="https://img.shields.io/website?down_message=board&label=product&up_color=blue&up_message=board&url=https%3A%2F%2Fsharing.clickup.com%2Fb%2Fxhcmx-63%2Fstrapiv-4-comments-board" />
720
+ </a>
721
+ </div>
368
722
 
369
723
  Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!
370
724
 
371
- ## Community support
725
+ ## 👨‍💻 Community support
372
726
 
373
727
  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:
374
728
 
375
- - [Discord](https://discord.strapi.io/) We're present on official Strapi Discord workspace. Look for @cyp3r and DM.
729
+ - [Discord](https://discord.strapi.io/) We're present on official Strapi Discord workspace. Find us by `[VirtusLab]` prefix and DM.
376
730
  - [Slack - VirtusLab Open Source](https://virtuslab-oss.slack.com) We're present on a public channel #strapi-molecules
377
731
  - [GitHub](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/issues) (Bug reports, Contributions, Questions and Discussions)
732
+ - [E-mail](mailto:strapi@virtuslab.com) - we will respond back as soon as possible
378
733
 
379
- ## License
734
+ ## 📝 License
380
735
 
381
736
  [MIT License](LICENSE.md) Copyright (c) [VirtusLab Sp. z o.o.](https://virtuslab.com/) &amp; [Strapi Solutions](https://strapi.io/).