strapi-plugin-comments 3.0.0-beta.0 → 3.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.
- package/README.md +83 -123
- package/dist/_chunks/{index-fAgatqD0.js → index-B-ygLKrb.js} +6080 -5662
- package/dist/_chunks/{index-fSb-gYwg.mjs → index-BgN4aUMA.mjs} +5 -5
- package/dist/_chunks/{index-h-TB6Qu2.mjs → index-Bx2boY6h.mjs} +6072 -5654
- package/dist/_chunks/{index-BQERo8pN.mjs → index-CIqMAf50.mjs} +1261 -1141
- package/dist/_chunks/{index-B6Q4U8YQ.js → index-CWfr5ejx.js} +27 -29
- package/dist/_chunks/{index-CTjupB9v.js → index-D8uskGzQ.js} +5 -5
- package/dist/_chunks/{index-BVj8EXjI.js → index-DFAPx7Bl.js} +1293 -1152
- package/dist/_chunks/{index-Bpbf7RON.mjs → index-Db2zwbpe.mjs} +27 -29
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/api/client.d.ts +33 -52
- package/dist/admin/src/api/schemas.d.ts +454 -764
- package/dist/admin/src/components/UserAvatar/index.d.ts +1 -1
- package/dist/admin/src/contexts/UserContext.d.ts +1 -1
- package/dist/admin/src/hooks/useAPI.d.ts +34 -53
- package/dist/admin/src/hooks/useCommentMutations.d.ts +1 -1
- package/dist/admin/src/hooks/useCommentsAll.d.ts +7 -10
- package/dist/admin/src/hooks/useReports.d.ts +6 -10
- package/dist/admin/src/hooks/useUserContext.d.ts +1 -1
- package/dist/admin/src/pages/Settings/hooks/useSettingsAPI.d.ts +1 -1
- package/dist/server/index.js +9307 -2467
- package/dist/server/index.mjs +9307 -2467
- package/dist/server/src/{@types-v5 → @types}/utils.d.ts +4 -0
- package/dist/server/src/bootstrap.d.ts +1 -1
- package/dist/server/src/config/index.d.ts +52 -0
- package/dist/server/src/content-types/index.d.ts +1 -1
- package/dist/server/src/controllers/admin.controller.d.ts +110 -29
- package/dist/server/src/controllers/client.controller.d.ts +151 -23
- package/dist/server/src/controllers/index.d.ts +504 -197
- package/dist/server/src/controllers/settings.controller.d.ts +58 -2
- package/dist/server/src/controllers/utils/parsers.d.ts +4 -1
- package/dist/server/src/graphql/getResolversConfig.d.ts +21 -0
- package/dist/server/src/graphql/index.d.ts +2 -0
- package/dist/server/src/graphql/mutations/getCreateAbuseReport.d.ts +95 -0
- package/dist/server/src/graphql/mutations/getCreateComment.d.ts +84 -0
- package/dist/server/src/graphql/mutations/getRemoveComment.d.ts +84 -0
- package/dist/server/src/graphql/mutations/getUpdateComment.d.ts +84 -0
- package/dist/server/src/graphql/mutations/index.d.ts +3 -0
- package/dist/server/src/graphql/queries/findAllFlat.d.ts +177 -0
- package/dist/server/src/graphql/queries/findAllInHierarchy.d.ts +87 -0
- package/dist/server/src/graphql/queries/findAllPerAuthor.d.ts +176 -0
- package/dist/server/src/graphql/queries/index.d.ts +3 -0
- package/dist/server/src/graphql/types/getComment.d.ts +2 -0
- package/dist/server/src/graphql/types/getCommentAuthor.d.ts +2 -0
- package/dist/server/src/graphql/types/getCommentAuthorType.d.ts +2 -0
- package/dist/server/src/graphql/types/getCommentNested.d.ts +2 -0
- package/dist/server/src/graphql/types/getCreateComment.d.ts +2 -0
- package/dist/server/src/graphql/types/getCreateCommentAuthor.d.ts +2 -0
- package/dist/server/src/graphql/types/getCreateReport.d.ts +2 -0
- package/dist/server/src/graphql/types/getId.d.ts +2 -0
- package/dist/server/src/graphql/types/getIdentityAuthor.d.ts +2 -0
- package/dist/server/src/graphql/types/getRemoveComment.d.ts +2 -0
- package/dist/server/src/graphql/types/getReport.d.ts +2 -0
- package/dist/server/src/graphql/types/getReportReason.d.ts +3 -0
- package/dist/server/src/graphql/types/getResponseFindAll.d.ts +2 -0
- package/dist/server/src/graphql/types/getResponseFindAllPerAuthor.d.ts +2 -0
- package/dist/server/src/graphql/types/getResponseMeta.d.ts +2 -0
- package/dist/server/src/graphql/types/getResponsePagination.d.ts +2 -0
- package/dist/server/src/graphql/types/getUpdateComment.d.ts +2 -0
- package/dist/server/src/graphql/types/index.d.ts +3 -0
- package/dist/server/src/index.d.ts +1686 -779
- package/dist/server/src/register/custom-fields/index.d.ts +1 -1
- package/dist/server/src/register/index.d.ts +1 -1
- package/dist/server/src/repositories/comment.repository.d.ts +10 -1
- package/dist/server/src/repositories/index.d.ts +0 -2
- package/dist/server/src/repositories/report.comment.repository.d.ts +38 -1
- package/dist/server/src/repositories/store.repository.d.ts +175 -4
- package/dist/server/src/repositories/utils.d.ts +1 -3
- package/dist/server/src/routes/admin.routes.d.ts +1 -1
- package/dist/server/src/routes/client.routes.d.ts +1 -1
- package/dist/server/src/routes/index.d.ts +2 -2
- package/dist/server/src/services/admin/admin.service.d.ts +399 -188
- package/dist/server/src/services/admin/utils.d.ts +1 -1
- package/dist/server/src/services/client.service.d.ts +343 -177
- package/dist/server/src/services/common.service.d.ts +66 -22
- package/dist/server/src/services/gql.service.d.ts +7 -0
- package/dist/server/src/services/index.d.ts +1131 -552
- package/dist/server/src/services/settings.service.d.ts +44 -2
- package/dist/server/src/services/utils/functions.d.ts +10 -6
- package/dist/server/src/test/utils.d.ts +1 -0
- package/dist/server/src/utils/constants.d.ts +1 -1
- package/dist/server/src/utils/getConfig.d.ts +2 -2
- package/dist/server/src/utils/getPluginService.d.ts +2 -2
- package/dist/server/src/utils/throwError.d.ts +1 -1
- package/dist/server/src/validators/api/controllers/client.controller.validator.d.ts +116 -80
- package/dist/server/src/validators/api/controllers/settings.controller.validator.d.ts +7 -3
- package/dist/server/src/validators/repositories/comment.schema.d.ts +18 -3
- package/dist/server/src/validators/repositories/comment.validator.d.ts +400 -72
- package/dist/server/src/validators/repositories/reports.validator.d.ts +60 -18
- package/dist/server/src/validators/utils.d.ts +1 -1
- package/package.json +18 -11
- /package/dist/server/src/{@types-v5 → @types}/controllers.d.ts +0 -0
- /package/dist/server/src/{@types-v5 → @types}/index.d.ts +0 -0
- /package/dist/server/src/{@types-v5 → @types}/repositories.d.ts +0 -0
- /package/dist/server/src/{@types-v5 → @types}/routes.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
<div align="center"
|
|
2
|
-
<img style="width: 150px; height: auto;" src="
|
|
1
|
+
<div align="center" style="max-width: 10rem; margin: 0 auto">
|
|
2
|
+
<img style="width: 150px; height: auto;" src="https://www.sensinum.com/img/open-source/strapi-plugin-comments/logo.png" alt="Logo - Strapi Comments plugin" />
|
|
3
3
|
</div>
|
|
4
4
|
<div align="center">
|
|
5
|
-
<h1>Strapi v5 - Comments plugin
|
|
5
|
+
<h1>Strapi v5 - Comments plugin</h1>
|
|
6
6
|
<p>Powerful Strapi based comments moderation tool for you and your users</p>
|
|
7
7
|
<a href="https://www.npmjs.org/package/strapi-plugin-comments">
|
|
8
|
-
<img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/VirtusLab-Open-Source/strapi-plugin-comments
|
|
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">
|
|
9
9
|
</a>
|
|
10
10
|
<a href="https://www.npmjs.org/package/strapi-plugin-comments">
|
|
11
11
|
<img src="https://img.shields.io/npm/dm/strapi-plugin-comments.svg" alt="Monthly download on NPM" />
|
|
12
12
|
</a>
|
|
13
13
|
<a href="https://circleci.com/gh/VirtusLab-Open-Source/strapi-plugin-comments">
|
|
14
|
-
<img src="https://circleci.com/gh/VirtusLab-Open-Source/strapi-plugin-comments
|
|
14
|
+
<img src="https://circleci.com/gh/VirtusLab-Open-Source/strapi-plugin-comments.svg?style=shield" alt="CircleCI" />
|
|
15
15
|
</a>
|
|
16
16
|
<a href="https://codecov.io/gh/VirtusLab-Open-Source/strapi-plugin-comments">
|
|
17
|
-
<img src="https://codecov.io/gh/VirtusLab-Open-Source/strapi-plugin-comments/coverage.svg?branch=
|
|
17
|
+
<img src="https://codecov.io/gh/VirtusLab-Open-Source/strapi-plugin-comments/coverage.svg?branch=master" alt="codecov.io" />
|
|
18
18
|
</a>
|
|
19
19
|
</div>
|
|
20
20
|
|
|
21
|
-
## ⚠️ This is the beta version for Strapi v5
|
|
22
|
-
|
|
23
21
|
---
|
|
24
22
|
|
|
25
23
|
<div style="margin: 20px 0" align="center">
|
|
26
|
-
<img style="width: 100%; height: auto;" src="
|
|
24
|
+
<img style="width: 100%; height: auto;" src="https://www.sensinum.com/img/open-source/strapi-plugin-comments/preview.png" alt="UI preview" />
|
|
27
25
|
</div>
|
|
28
26
|
|
|
29
27
|
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.
|
|
@@ -39,30 +37,29 @@ A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provid
|
|
|
39
37
|
- [Plugin file](#in-v202-and-older--default-configuration-state-for-v203-and-newer)
|
|
40
38
|
6. [🕸️ Public API - REST](#%EF%B8%8F-public-rest-api-specification)
|
|
41
39
|
7. [🕸️ Public API - GraphQL](#%EF%B8%8F-public-graphql-specification)
|
|
42
|
-
8. [
|
|
43
|
-
9. [
|
|
44
|
-
10. [
|
|
40
|
+
8. [🌿 Model lifecycle hooks](#model-life-cycle-hooks)
|
|
41
|
+
9. [⚗️ Custom fields](#-custom-fields)
|
|
42
|
+
10. [🧩 Examples](#-examples)
|
|
43
|
+
11. [💬 FAQ](#-faq)
|
|
44
|
+
12. [🤝 Contributing](#-contributing)
|
|
45
|
+
13. [👨💻 Community support](#-community-support)
|
|
45
46
|
|
|
46
47
|
## 💎 Versions
|
|
47
|
-
|
|
48
|
-
- **Strapi
|
|
48
|
+
|
|
49
|
+
- **Strapi v5** - (current) [v3.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments)
|
|
50
|
+
- **Strapi v4** - [v2.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/tree/strapi-v4)
|
|
49
51
|
- **Strapi v3** - [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/tree/strapi-v3)
|
|
50
52
|
|
|
51
53
|
## ✨ Features
|
|
52
54
|
|
|
53
55
|
- **Comments Public REST + GraphQL API:** Elegant, entirely customizable and a fully extensible admin panel.
|
|
54
56
|
- **Strapi & generic users:** Support for built-in & also generic non-Strapi users that might be the comments authors.
|
|
55
|
-
- **Strapi Custom Fields support:** Improve an experience of your Content Types by using [dedicated set of custom fields](https://docs-next.strapi.io/
|
|
57
|
+
- **Strapi Custom Fields support:** Improve an experience of your Content Types by using [dedicated set of custom fields](https://docs-next.strapi.io/dev-docs/custom-fields) for each of them and automate client side processing of Comments.
|
|
56
58
|
- **Any Content Type relation:** Comments can be linked to any of your Content Types by default. Simply, you're controlling it.
|
|
57
59
|
- **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.
|
|
58
60
|
- **Automated Bad Words filtering:** By default end users are not allowed to post abusing comments where bad words have been used.
|
|
59
61
|
- **Abuse Reporting & Reviewing:** Don't allow inferior language, react to reports from your community, send email notifications about issued reports
|
|
60
62
|
|
|
61
|
-
## ⚙️ Versions
|
|
62
|
-
|
|
63
|
-
- **Strapi v4** - (current) - [v2.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments)
|
|
64
|
-
- **Strapi v3** - [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/tree/strapi-v3)
|
|
65
|
-
|
|
66
63
|
## ⏳ Installation
|
|
67
64
|
|
|
68
65
|
### Via Strapi Marketplace
|
|
@@ -70,7 +67,7 @@ A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provid
|
|
|
70
67
|
As a ✅ **verified** plugin by Strapi team we're available on the [**Strapi Marketplace**](https://market.strapi.io/plugins/strapi-plugin-comments) as well as **In-App Marketplace** where you can follow the installation instructions.
|
|
71
68
|
|
|
72
69
|
<div style="margin: 20px 0" align="center">
|
|
73
|
-
<img style="width: 100%; height: auto;" src="
|
|
70
|
+
<img style="width: 100%; height: auto;" src="https://www.sensinum.com/img/open-source/strapi-plugin-comments/marketplace.png" alt="Strapi In-App Marketplace" />
|
|
74
71
|
</div>
|
|
75
72
|
|
|
76
73
|
### Via command line
|
|
@@ -88,85 +85,56 @@ yarn build
|
|
|
88
85
|
yarn develop
|
|
89
86
|
```
|
|
90
87
|
|
|
91
|
-
or just run Strapi in the development mode with `--watch-admin` option:
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
yarn develop --watch-admin
|
|
95
|
-
```
|
|
96
|
-
|
|
97
88
|
The **Comments** plugin should appear in the **Plugins** section of Strapi sidebar after you run app again.
|
|
98
89
|
|
|
99
90
|
As a next step you must configure your the plugin by the way you want to. See [**Configuration**](#🔧-configuration) section.
|
|
100
91
|
|
|
101
92
|
All done. Enjoy 🎉
|
|
102
93
|
|
|
103
|
-
### Working in development mode
|
|
104
|
-
|
|
105
|
-
1. Clone repository
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
git clone git@github.com:VirtusLab-Open-Source/strapi-plugin-comments.git
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
2. Create a soft link in your strapi project to plugin build folder
|
|
112
|
-
|
|
113
|
-
```sh
|
|
114
|
-
ln -s <your path>/strapi-plugin-comments/build <your path>/strapi-project/src/plugins/comments
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
3. Run develop or build command
|
|
118
|
-
|
|
119
|
-
```ts
|
|
120
|
-
// Watch for file changes
|
|
121
|
-
yarn develop
|
|
122
|
-
// or run build without nodemon
|
|
123
|
-
yarn build:dev
|
|
124
|
-
```
|
|
125
|
-
|
|
126
94
|
## 🖐 Requirements
|
|
127
95
|
|
|
128
|
-
Complete installation requirements are exact same as for Strapi itself and can be found in the documentation under [Installation Requirements](https://docs.strapi.io/
|
|
96
|
+
Complete installation requirements are exact same as for Strapi itself and can be found in the documentation under [Installation Requirements](https://docs.strapi.io/dev-docs/intro).
|
|
129
97
|
|
|
130
98
|
**Minimum environment requirements**
|
|
131
99
|
|
|
132
|
-
- Node.js `>=18.0.0 <=
|
|
100
|
+
- Node.js `>=18.0.0 <=22.x.x`
|
|
133
101
|
- NPM `>=6.x.x`
|
|
134
102
|
|
|
135
103
|
In our minimum support we're following [official Node.js releases timelines](https://nodejs.org/en/about/releases/).
|
|
136
104
|
|
|
137
105
|
**Supported Strapi versions**:
|
|
138
106
|
|
|
139
|
-
- Strapi
|
|
140
|
-
- Strapi
|
|
107
|
+
- Strapi v5.6.0 (recently tested)
|
|
108
|
+
- Strapi v5.x
|
|
141
109
|
|
|
142
|
-
> This plugin is designed for **Strapi
|
|
110
|
+
> This plugin is designed for **Strapi v5**. To get support for other Strapi versions, please follow the [versions](#-versions) section.
|
|
143
111
|
|
|
144
112
|
**Plugin dependencies**
|
|
145
|
-
- `@strapi/plugin-graphql` - required to run
|
|
113
|
+
- `@strapi/plugin-graphql` - required to run GraphQL handled by this plugin
|
|
146
114
|
|
|
147
115
|
**We recommend always using the latest version of Strapi to start your new projects**.
|
|
148
116
|
|
|
149
117
|
## 🔧 Configuration
|
|
150
118
|
|
|
151
|
-
To start your journey with **Comments plugin** you must first setup it using the dedicated Settings page
|
|
119
|
+
To start your journey with **Comments plugin** you must first setup it using the dedicated Settings page or for any version, put your configuration in `config/plugins.{js|ts}`. Anyway we're recommending the click-through option where your configuration is going to be properly validated.
|
|
152
120
|
|
|
153
|
-
###
|
|
121
|
+
### Settings page
|
|
154
122
|
|
|
155
|
-
|
|
123
|
+
On the dedicated page, you will be able to set up all crucial properties which drive the plugin and customize each individual collection for which **Comments plugin** should be enabled.
|
|
156
124
|
|
|
157
125
|
<div style="margin: 20px 0" align="center">
|
|
158
|
-
<img style="width: 100%; height: auto;" src="
|
|
126
|
+
<img style="width: 100%; height: auto;" src="https://www.sensinum.com/img/open-source/strapi-plugin-comments/configuration.png" alt="Plugin configuration" />
|
|
159
127
|
</div>
|
|
160
128
|
|
|
161
129
|
> _Note_
|
|
162
|
-
> Default configuration for your plugin is fetched from `config/plugins.js` or directly from the plugin itself. If you would like to customize the default state to which you might revert, please follow the next section.
|
|
130
|
+
> Default configuration for your plugin is fetched from `config/plugins.{js|ts}` or directly from the plugin itself. If you would like to customize the default state to which you might revert, please follow the next section.
|
|
163
131
|
|
|
164
|
-
###
|
|
132
|
+
### File
|
|
165
133
|
|
|
166
|
-
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.
|
|
134
|
+
To setup amend default plugin configuration we recommend to put following snippet as part of `config/plugins.{js|ts}` or `config/<env>/plugins.{js|ts}` 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.
|
|
167
135
|
|
|
168
|
-
```
|
|
169
|
-
module.exports = ({ env }) => ({
|
|
136
|
+
```ts
|
|
137
|
+
module.exports = ({ env }) => ({
|
|
170
138
|
//...
|
|
171
139
|
comments: {
|
|
172
140
|
enabled: true,
|
|
@@ -195,7 +163,7 @@ module.exports = ({ env }) => ({
|
|
|
195
163
|
|
|
196
164
|
- `enabledCollections` - list of Collection and Single Types for which plugin should be enabled in format like `'api::<collection name>.<content type name>'`. By default it's empty and none comments are not enabled for any of type in Strapi.
|
|
197
165
|
- `no-profanity` - Enabled support for [profanity filtering](https://www.npmjs.com/package/no-profanity). Can be turned off or altered using the [options reference](https://www.npmjs.com/package/no-profanity?activeTab=readme#options). Default value: `true`.
|
|
198
|
-
- `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/
|
|
166
|
+
- `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/dev-docs/plugins/email) configured.
|
|
199
167
|
- `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.
|
|
200
168
|
- `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 `*`.
|
|
201
169
|
- `reportReasons` - set of enums you would like to use for issuing abuse reports. Provided by default `'BAD_LANGUAGE'`, `'DISCRIMINATION'` and `'OTHER'`.
|
|
@@ -204,10 +172,10 @@ module.exports = ({ env }) => ({
|
|
|
204
172
|
|
|
205
173
|
## Additional GQL Configuration
|
|
206
174
|
|
|
207
|
-
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/
|
|
175
|
+
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/dev-docs/plugins/graphql#configurations)** and decide if you would like to call it by anyone (open for world) or only by authenticated users (Strapi users).
|
|
208
176
|
|
|
209
177
|
> **Important!**
|
|
210
|
-
> If you're using `config/plugins.js` to configure your plugins , please put `comments` property before `graphql`. Otherwise types are not going to be properly added to GraphQL Schema. That's because of dynamic types which base on plugin configuration which are added on `boostrap` stage, not `register`. This is not valid if you're using `graphql` plugin without any custom configuration, so most of cases in real.
|
|
178
|
+
> If you're using `config/plugins.{js|ts}` to configure your plugins , please put `comments` property before `graphql`. Otherwise types are not going to be properly added to GraphQL Schema. That's because of dynamic types which base on plugin configuration which are added on `boostrap` stage, not `register`. This is not valid if you're using `graphql` plugin without any custom configuration, so most of cases in real.
|
|
211
179
|
|
|
212
180
|
```json
|
|
213
181
|
{
|
|
@@ -258,7 +226,7 @@ Feature / Capability focused permissions:
|
|
|
258
226
|
|
|
259
227
|
```json
|
|
260
228
|
{
|
|
261
|
-
"
|
|
229
|
+
"documentId": "njx99iv4p4txuqp307ye8625",
|
|
262
230
|
"content": "My comment content",
|
|
263
231
|
"blocked": null,
|
|
264
232
|
"blockedThread": true,
|
|
@@ -289,11 +257,11 @@ Feature / Capability focused permissions:
|
|
|
289
257
|
|
|
290
258
|
_GraphQL equivalent: [Public GraphQL API -> Get Comments](#get-comments-1)_
|
|
291
259
|
|
|
292
|
-
`GET <host>/api/comments/api::<collection name>.<content type name>:<entity id>`
|
|
260
|
+
`GET <host>/api/comments/api::<collection name>.<content type name>:<entity document id>`
|
|
293
261
|
|
|
294
|
-
Return a hierarchical tree structure of comments for specified instance of Content Type like for example `Page` with `
|
|
262
|
+
Return a hierarchical tree structure of comments for specified instance of Content Type like for example `Page` with `documentId: njx99iv4p4txuqp307ye8625`.
|
|
295
263
|
|
|
296
|
-
**Example URL**: `https://localhost:1337/api/comments/api::page.page:
|
|
264
|
+
**Example URL**: `https://localhost:1337/api/comments/api::page.page:njx99iv4p4txuqp307ye8625`
|
|
297
265
|
|
|
298
266
|
**Example response body**
|
|
299
267
|
|
|
@@ -317,18 +285,18 @@ Return a hierarchical tree structure of comments for specified instance of Conte
|
|
|
317
285
|
|
|
318
286
|
#### Strapi REST API properties support:
|
|
319
287
|
|
|
320
|
-
- [field selection](https://docs.strapi.io/
|
|
321
|
-
- [sorting](https://docs.strapi.io/
|
|
288
|
+
- [field selection](https://docs.strapi.io/dev-docs/api/rest/populate-select#field-selection)
|
|
289
|
+
- [sorting](https://docs.strapi.io/dev-docs/api/rest/sort-pagination#sorting)
|
|
322
290
|
|
|
323
291
|
### Get Comments (flat structure)
|
|
324
292
|
|
|
325
293
|
_GraphQL equivalent: [Public GraphQL API -> Get Comments (flat structure)](#get-comments-flat-structure-1)_
|
|
326
294
|
|
|
327
|
-
`GET <host>/api/comments/api::<collection name>.<content type name>:<entity id>/flat`
|
|
295
|
+
`GET <host>/api/comments/api::<collection name>.<content type name>:<entity document id>/flat`
|
|
328
296
|
|
|
329
|
-
Return a flat structure of comments for specified instance of Content Type like for example `Page` with `
|
|
297
|
+
Return a flat structure of comments for specified instance of Content Type like for example `Page` with `documentId: njx99iv4p4txuqp307ye8625`
|
|
330
298
|
|
|
331
|
-
**Example URL**: `https://localhost:1337/api/comments/api::page.page:
|
|
299
|
+
**Example URL**: `https://localhost:1337/api/comments/api::page.page:njx99iv4p4txuqp307ye8625/flat`
|
|
332
300
|
|
|
333
301
|
**Example response body**
|
|
334
302
|
|
|
@@ -358,10 +326,10 @@ Return a flat structure of comments for specified instance of Content Type like
|
|
|
358
326
|
|
|
359
327
|
#### Strapi REST API properties support:
|
|
360
328
|
|
|
361
|
-
- [filtering](https://docs.strapi.io/
|
|
362
|
-
- [field selection](https://docs.strapi.io/
|
|
363
|
-
- [sorting](https://docs.strapi.io/
|
|
364
|
-
- [pagination](https://docs.strapi.io/
|
|
329
|
+
- [filtering](https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#filtering)
|
|
330
|
+
- [field selection](https://docs.strapi.io/dev-docs/api/rest/populate-select#field-selection)
|
|
331
|
+
- [sorting](https://docs.strapi.io/dev-docs/api/rest/sort-pagination#sorting)
|
|
332
|
+
- [pagination](https://docs.strapi.io/dev-docs/api/rest/sort-pagination#pagination)
|
|
365
333
|
|
|
366
334
|
### Get Comments (by Author)
|
|
367
335
|
|
|
@@ -371,8 +339,8 @@ _GraphQL equivalent: [Public GraphQL API -> Get Comments (by Author)](#get-comme
|
|
|
371
339
|
|
|
372
340
|
Return a flat structure of comments by specified Author for example `Author` with `ID: 1`
|
|
373
341
|
|
|
374
|
-
**Example URL**: `https://localhost:1337/api/comments/author/1` - get comments by `ID:1` of Strapi User
|
|
375
|
-
**Example URL**: `https://localhost:1337/api/comments/author/1/generic` - get comments by `ID:1` of Generic User
|
|
342
|
+
**Example URL**: `https://localhost:1337/api/comments/author/1` - get comments by `ID: 1` of Strapi User
|
|
343
|
+
**Example URL**: `https://localhost:1337/api/comments/author/1/generic` - get comments by `ID: 1` of Generic User
|
|
376
344
|
|
|
377
345
|
#### Skipping fields
|
|
378
346
|
|
|
@@ -408,20 +376,20 @@ To skip a field from the response you can use a query param called `omit`. It is
|
|
|
408
376
|
|
|
409
377
|
#### Strapi REST API properties support:
|
|
410
378
|
|
|
411
|
-
- [filtering](https://docs.strapi.io/
|
|
412
|
-
- [field selection](https://docs.strapi.io/
|
|
413
|
-
- [sorting](https://docs.strapi.io/
|
|
414
|
-
- [pagination](https://docs.strapi.io/
|
|
379
|
+
- [filtering](https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#filtering)
|
|
380
|
+
- [field selection](https://docs.strapi.io/dev-docs/api/rest/populate-select#field-selection)
|
|
381
|
+
- [sorting](https://docs.strapi.io/dev-docs/api/rest/sort-pagination#sorting)
|
|
382
|
+
- [pagination](https://docs.strapi.io/dev-docs/api/rest/sort-pagination#pagination)
|
|
415
383
|
|
|
416
384
|
### Post a Comment
|
|
417
385
|
|
|
418
386
|
_GraphQL equivalent: [Public GraphQL API -> Post a Comments](#post-a-comment-1)_
|
|
419
387
|
|
|
420
|
-
`POST <host>/api/comments/api::<collection name>.<content type name>:<entity id>`
|
|
388
|
+
`POST <host>/api/comments/api::<collection name>.<content type name>:<entity document id>`
|
|
421
389
|
|
|
422
|
-
Posts a Comment related to specified instance of Content Type like for example `Page` with `
|
|
390
|
+
Posts a Comment related to specified instance of Content Type like for example `Page` with `documentId: njx99iv4p4txuqp307ye8625`
|
|
423
391
|
|
|
424
|
-
**Example URL**: `https://localhost:1337/api/comments/api::page.page:
|
|
392
|
+
**Example URL**: `https://localhost:1337/api/comments/api::page.page:njx99iv4p4txuqp307ye8625`
|
|
425
393
|
|
|
426
394
|
**Example request body**
|
|
427
395
|
|
|
@@ -468,11 +436,11 @@ _Strapi user_
|
|
|
468
436
|
|
|
469
437
|
_GraphQL equivalent: [Public GraphQL API -> Update Comments](#update-comment-1)_
|
|
470
438
|
|
|
471
|
-
`PUT <host>/api/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>`
|
|
439
|
+
`PUT <host>/api/comments/api::<collection name>.<content type name>:<entity document id>/comment/<commentId>`
|
|
472
440
|
|
|
473
|
-
Updates a specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `
|
|
441
|
+
Updates a specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `documentId: njx99iv4p4txuqp307ye8625`
|
|
474
442
|
|
|
475
|
-
**Example URL**: `https://localhost:1337/api/comments/api::page.page:
|
|
443
|
+
**Example URL**: `https://localhost:1337/api/comments/api::page.page:njx99iv4p4txuqp307ye8625/comment/2`
|
|
476
444
|
|
|
477
445
|
**Example request body**
|
|
478
446
|
|
|
@@ -515,11 +483,11 @@ _Strapi user_
|
|
|
515
483
|
|
|
516
484
|
_GraphQL equivalent: [Public GraphQL API -> Delete Comment](#delete-comment-1)_
|
|
517
485
|
|
|
518
|
-
`DELETE <host>/api/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>?authorId=<authorId>`
|
|
486
|
+
`DELETE <host>/api/comments/api::<collection name>.<content type name>:<entity document id>/comment/<commentId>?authorId=<authorId>`
|
|
519
487
|
|
|
520
|
-
Deletes a specified Comment based on it `commentId` and related to specified instance of Content Type like for example `Page` with `
|
|
488
|
+
Deletes a specified Comment based on it `commentId` and related to specified instance of Content Type like for example `Page` with `documentId: njx99iv4p4txuqp307ye8625`.
|
|
521
489
|
|
|
522
|
-
**Example URL**: `https://localhost:1337/api/comments/api::page.page:
|
|
490
|
+
**Example URL**: `https://localhost:1337/api/comments/api::page.page:njx99iv4p4txuqp307ye8625/comment/1?authorId=1`
|
|
523
491
|
|
|
524
492
|
**Example response body**
|
|
525
493
|
|
|
@@ -538,11 +506,11 @@ Deletes a specified Comment based on it `commentId` and related to specified ins
|
|
|
538
506
|
|
|
539
507
|
_GraphQL equivalent: [Public GraphQL API -> Issue Abuse Report against specified Comment](#issue-abuse-report-against-specified-comment-1)_
|
|
540
508
|
|
|
541
|
-
`POST <host>/api/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>/report-abuse`
|
|
509
|
+
`POST <host>/api/comments/api::<collection name>.<content type name>:<entity document id>/comment/<commentId>/report-abuse`
|
|
542
510
|
|
|
543
|
-
Reports abuse in specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `
|
|
511
|
+
Reports abuse in specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `documentId: njx99iv4p4txuqp307ye8625` and requests moderator attention.
|
|
544
512
|
|
|
545
|
-
**Example URL**: `https://localhost:1337/api/comments/api::page.page:
|
|
513
|
+
**Example URL**: `https://localhost:1337/api/comments/api::page.page:njx99iv4p4txuqp307ye8625/comment/2/report-abuse`
|
|
546
514
|
|
|
547
515
|
**Example request body**
|
|
548
516
|
|
|
@@ -586,7 +554,7 @@ _REST API equivalent: [Public REST API -> Get Comments](#get-comments)_
|
|
|
586
554
|
|
|
587
555
|
```graphql
|
|
588
556
|
query {
|
|
589
|
-
findAllInHierarchy(relation: "api::page.page:
|
|
557
|
+
findAllInHierarchy(relation: "api::page.page:njx99iv4p4txuqp307ye8625") {
|
|
590
558
|
id
|
|
591
559
|
content
|
|
592
560
|
blocked
|
|
@@ -636,7 +604,7 @@ query {
|
|
|
636
604
|
|
|
637
605
|
#### Strapi GraphQL API properties support:
|
|
638
606
|
|
|
639
|
-
- [sorting](https://docs.strapi.io/
|
|
607
|
+
- [sorting](https://docs.strapi.io/dev-docs/api/rest/sort-pagination#sorting)
|
|
640
608
|
|
|
641
609
|
### Get Comments (flat structure)
|
|
642
610
|
|
|
@@ -647,7 +615,7 @@ _REST API equivalent: [Public REST API -> Get Comments (flat structure)](#get-co
|
|
|
647
615
|
```graphql
|
|
648
616
|
query {
|
|
649
617
|
findAllFlat(
|
|
650
|
-
relation: "api::page.page:
|
|
618
|
+
relation: "api::page.page:njx99iv4p4txuqp307ye8625"
|
|
651
619
|
filters: { content: { contains: "Test" } }
|
|
652
620
|
) {
|
|
653
621
|
id
|
|
@@ -683,13 +651,14 @@ query {
|
|
|
683
651
|
// ...
|
|
684
652
|
]
|
|
685
653
|
}
|
|
654
|
+
}
|
|
686
655
|
```
|
|
687
656
|
|
|
688
657
|
#### Strapi GraphQL API properties support:
|
|
689
658
|
|
|
690
|
-
- [filtering](https://docs.strapi.io/
|
|
691
|
-
- [sorting](https://docs.strapi.io/
|
|
692
|
-
- [pagination](https://docs.strapi.io/
|
|
659
|
+
- [filtering](https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#filtering)
|
|
660
|
+
- [sorting](https://docs.strapi.io/dev-docs/api/rest/sort-pagination#sorting)
|
|
661
|
+
- [pagination](https://docs.strapi.io/dev-docs/api/rest/sort-pagination#pagination)
|
|
693
662
|
|
|
694
663
|
### Get Comments (by Author)
|
|
695
664
|
|
|
@@ -736,9 +705,9 @@ query {
|
|
|
736
705
|
|
|
737
706
|
#### Strapi GraphQL API properties support:
|
|
738
707
|
|
|
739
|
-
- [filtering](https://docs.strapi.io/
|
|
740
|
-
- [sorting](https://docs.strapi.io/
|
|
741
|
-
- [pagination](https://docs.strapi.io/
|
|
708
|
+
- [filtering](https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#filtering)
|
|
709
|
+
- [sorting](https://docs.strapi.io/dev-docs/api/rest/sort-pagination#sorting)
|
|
710
|
+
- [pagination](https://docs.strapi.io/dev-docs/api/rest/sort-pagination#pagination)
|
|
742
711
|
|
|
743
712
|
### Post a Comment
|
|
744
713
|
|
|
@@ -750,7 +719,7 @@ _REST API equivalent: [Public REST API -> Post a Comment](#post-a-comment)_
|
|
|
750
719
|
mutation createComment {
|
|
751
720
|
createComment(
|
|
752
721
|
input: {
|
|
753
|
-
relation: "api::page.page:
|
|
722
|
+
relation: "api::page.page:njx99iv4p4txuqp307ye8625"
|
|
754
723
|
content: "Hello World!"
|
|
755
724
|
threadOf: 3
|
|
756
725
|
author: { id: "12345678", name: "John Wick", email: "test@test.pl" } # Optional if using auth / authz requests
|
|
@@ -800,7 +769,7 @@ mutation updateComment {
|
|
|
800
769
|
updateComment(
|
|
801
770
|
input: {
|
|
802
771
|
id: 34
|
|
803
|
-
relation: "api::page.page:
|
|
772
|
+
relation: "api::page.page:njx99iv4p4txuqp307ye8625"
|
|
804
773
|
content: "I've changed it!"
|
|
805
774
|
author: { id: "12345678" } # Optional if using auth / authz requests
|
|
806
775
|
}
|
|
@@ -853,7 +822,7 @@ mutation removeComment {
|
|
|
853
822
|
removeComment(
|
|
854
823
|
input: {
|
|
855
824
|
id: 33
|
|
856
|
-
relation: "api::page.page:
|
|
825
|
+
relation: "api::page.page:njx99iv4p4txuqp307ye8625"
|
|
857
826
|
author: { id: "12345678" } # Optional if using auth / authz requests
|
|
858
827
|
}
|
|
859
828
|
) {
|
|
@@ -887,7 +856,7 @@ mutation createAbuseReport {
|
|
|
887
856
|
createAbuseReport(
|
|
888
857
|
input: {
|
|
889
858
|
commentId: 34
|
|
890
|
-
relation: "api::page.page:
|
|
859
|
+
relation: "api::page.page:njx99iv4p4txuqp307ye8625"
|
|
891
860
|
reason: BAD_LANGUAGE
|
|
892
861
|
content: "Rude language"
|
|
893
862
|
}
|
|
@@ -931,13 +900,13 @@ _Available reason enums:_ `BAD_WORDS`, `OTHER`, `DISCRIMINATION` (want more? See
|
|
|
931
900
|
|
|
932
901
|
## 🧩 Examples
|
|
933
902
|
|
|
934
|
-
Live example of plugin usage can be found in the [VirtusLab Strapi Examples](https://github.com/VirtusLab/strapi-examples/tree/master/strapi-
|
|
903
|
+
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.
|
|
935
904
|
|
|
936
905
|
## ⚗️ Custom fields
|
|
937
906
|
|
|
938
907
|
For developers who upgrades their Strapi instance custom field from Comments plugin is available. Custom field can be picked from content types' edit page or added in definition file.
|
|
939
908
|
|
|
940
|
-
Read more about this feature in [Strapi's docs](https://docs-next.strapi.io/
|
|
909
|
+
Read more about this feature in [Strapi's docs](https://docs-next.strapi.io/dev-docs/custom-fields).
|
|
941
910
|
|
|
942
911
|
## Model lifecycle hooks
|
|
943
912
|
|
|
@@ -981,15 +950,6 @@ Example:
|
|
|
981
950
|
|
|
982
951
|
## 🤝 Contributing
|
|
983
952
|
|
|
984
|
-
<div>
|
|
985
|
-
<a href="https://sharing.clickup.com/tl/xhcmx-83/strapiv-4-comments-roadmap">
|
|
986
|
-
<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" />
|
|
987
|
-
</a>
|
|
988
|
-
<a href="https://sharing.clickup.com/b/xhcmx-63/strapiv-4-comments-board">
|
|
989
|
-
<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" />
|
|
990
|
-
</a>
|
|
991
|
-
</div>
|
|
992
|
-
|
|
993
953
|
Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!
|
|
994
954
|
|
|
995
955
|
## 👨💻 Community support
|