strapi-plugin-comments 1.0.1 → 2.0.0-beta.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/.circleci/config.yml +2 -2
- package/.nvmrc +1 -1
- package/README.md +71 -95
- package/admin/src/components/ConfirmationDialog/index.js +56 -0
- package/admin/src/components/DiscussionStatus/index.js +33 -0
- package/admin/src/components/DiscussionThread/index.js +58 -0
- package/admin/src/components/DiscussionThreadItem/index.js +87 -0
- package/admin/src/components/DiscussionThreadItem/styles.js +87 -0
- package/admin/src/components/DiscussionThreadItemActions/index.js +176 -0
- package/admin/src/components/DiscussionThreadItemActions/styles.js +22 -0
- package/admin/src/components/DiscussionThreadItemMeta/index.js +31 -0
- package/admin/src/components/DiscussionThreadItemWarnings/index.js +137 -0
- package/admin/src/components/DiscussionThreadItemWarnings/styles.js +7 -0
- package/admin/src/components/EntityDetails/index.js +53 -0
- package/admin/src/{containers → components}/Initializer/index.js +4 -4
- package/admin/src/components/LoadingIndicatorOverlay/index.js +15 -0
- package/admin/src/components/LoadingIndicatorOverlay/styles.js +20 -0
- package/admin/src/components/Nav/index.js +45 -0
- package/admin/src/components/PluginIcon/index.js +12 -0
- package/admin/src/components/ReportsReviewModal/index.js +45 -0
- package/admin/src/components/ReportsReviewTable/index.js +142 -0
- package/admin/src/components/TableFilters/index.js +53 -0
- package/admin/src/components/TablePagination/index.js +35 -0
- package/admin/src/components/icons/comments.js +9 -0
- package/admin/src/index.js +56 -42
- package/admin/src/pages/App/index.js +32 -0
- package/admin/src/pages/ComingSoonPage/index.js +25 -0
- package/admin/src/pages/Details/index.js +109 -0
- package/admin/src/pages/Details/utils/api.js +41 -0
- package/admin/src/pages/Discover/index.js +185 -0
- package/admin/src/pages/Discover/utils/api.js +23 -0
- package/admin/src/pages/Discover/utils/filtersSchema.js +9 -0
- package/admin/src/permissions.js +13 -33
- package/admin/src/pluginId.js +2 -4
- package/admin/src/translations/en.json +72 -33
- package/admin/src/translations/fr.json +1 -0
- package/admin/src/utils/axiosInstance.js +35 -0
- package/admin/src/utils/constants.js +28 -0
- package/admin/src/utils/getApiUrl.js +5 -0
- package/admin/src/utils/getMessage.js +14 -0
- package/admin/src/utils/getRelatedGroups.js +5 -0
- package/admin/src/utils/getUrl.js +5 -0
- package/admin/src/utils/handleAPIError.js +15 -0
- package/admin/src/utils/index.js +6 -0
- package/codecov.yml +2 -1
- package/content-types/comment.js +97 -0
- package/content-types/index.js +11 -0
- package/content-types/report.js +54 -0
- package/package.json +12 -26
- package/server/bootstrap.js +5 -0
- package/server/config/index.js +6 -0
- package/server/controllers/admin.js +150 -0
- package/server/controllers/client.js +109 -0
- package/server/controllers/index.js +9 -0
- package/{controllers → server/controllers}/utils/__tests__/functions.test.js +0 -0
- package/{controllers → server/controllers}/utils/functions.js +1 -1
- package/server/destroy.js +5 -0
- package/server/index.js +22 -0
- package/server/register.js +5 -0
- package/server/routes/admin.js +92 -0
- package/server/routes/client.js +52 -0
- package/server/routes/index.js +15 -0
- package/server/services/admin.js +180 -0
- package/server/services/client.js +227 -0
- package/server/services/common.js +191 -0
- package/server/services/index.js +11 -0
- package/{services → server/services}/utils/__tests__/functions.test.js +7 -9
- package/{services → server/services}/utils/functions.js +19 -8
- package/server/utils/constants.js +16 -0
- package/{services → server}/utils/error.js +0 -0
- package/server/utils/functions.js +19 -0
- package/strapi-admin.js +3 -0
- package/strapi-server.js +9 -0
- package/admin/src/assets/images/icon-cross-blue.svg +0 -1
- package/admin/src/assets/images/icon_remove.svg +0 -19
- package/admin/src/assets/images/logo.svg +0 -5
- package/admin/src/components/AbuseReportsPopUp/ItemPreviewContainer.js +0 -8
- package/admin/src/components/AbuseReportsPopUp/ModalFooter.js +0 -31
- package/admin/src/components/AbuseReportsPopUp/TableContainer.js +0 -63
- package/admin/src/components/AbuseReportsPopUp/index.js +0 -148
- package/admin/src/components/Container/index.js +0 -7
- package/admin/src/components/EmptyView/index.js +0 -25
- package/admin/src/components/Filters/index.js +0 -151
- package/admin/src/components/Filters/index.styled.js +0 -82
- package/admin/src/components/Filters/utils.js +0 -21
- package/admin/src/components/Item/CardItem.js +0 -30
- package/admin/src/components/Item/CardWrapper.js +0 -10
- package/admin/src/components/Item/index.js +0 -92
- package/admin/src/components/ItemDetails/CardItem.js +0 -33
- package/admin/src/components/ItemDetails/CardLevelCounter.js +0 -46
- package/admin/src/components/ItemDetails/CardLevelCounterLink.js +0 -24
- package/admin/src/components/ItemDetails/CardLevelWrapper.js +0 -22
- package/admin/src/components/ItemDetails/CardWrapper.js +0 -52
- package/admin/src/components/ItemDetails/index.js +0 -151
- package/admin/src/components/ItemFooter/CardItemAuthor.js +0 -10
- package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
- package/admin/src/components/ItemFooter/Wrapper.js +0 -20
- package/admin/src/components/ItemFooter/index.js +0 -87
- package/admin/src/components/ItemHeader/CardHeaderBlocked.js +0 -24
- package/admin/src/components/ItemHeader/CardHeaderIndicator.js +0 -30
- package/admin/src/components/ItemHeader/CardHeaderIndicatorBlue.js +0 -11
- package/admin/src/components/ItemHeader/CardHeaderIndicatorRed.js +0 -11
- package/admin/src/components/ItemHeader/CardHeaderIndicatorsContainer.js +0 -18
- package/admin/src/components/ItemHeader/CardHeaderReports.js +0 -40
- package/admin/src/components/ItemHeader/Wrapper.js +0 -16
- package/admin/src/components/ItemHeader/index.js +0 -80
- package/admin/src/components/ItemModeration/Wrapper.js +0 -19
- package/admin/src/components/ItemModeration/index.js +0 -47
- package/admin/src/components/List/Container.js +0 -20
- package/admin/src/components/List/index.js +0 -21
- package/admin/src/components/Search/index.js +0 -83
- package/admin/src/containers/App/Wrapper.js +0 -14
- package/admin/src/containers/App/index.js +0 -47
- package/admin/src/containers/DataManagerProvider/actions.js +0 -11
- package/admin/src/containers/DataManagerProvider/index.js +0 -280
- package/admin/src/containers/DataManagerProvider/init.js +0 -5
- package/admin/src/containers/DataManagerProvider/reducer.js +0 -59
- package/admin/src/containers/DetailsView/Wrapper.js +0 -18
- package/admin/src/containers/DetailsView/index.js +0 -100
- package/admin/src/containers/ListView/FadedWrapper.js +0 -42
- package/admin/src/containers/ListView/Footer.js +0 -53
- package/admin/src/containers/ListView/Wrapper.js +0 -17
- package/admin/src/containers/ListView/components.js +0 -138
- package/admin/src/containers/ListView/index.js +0 -45
- package/admin/src/containers/Panel/actions.js +0 -5
- package/admin/src/containers/Panel/index.js +0 -191
- package/admin/src/containers/Panel/index.styled.js +0 -6
- package/admin/src/containers/Panel/reducer.js +0 -44
- package/admin/src/contexts/DataManagerContext.js +0 -5
- package/admin/src/hooks/useDataManager.js +0 -6
- package/admin/src/lifecycles.js +0 -3
- package/admin/src/translations/index.js +0 -7
- package/admin/src/utils/getTrad.js +0 -5
- package/admin/src/utils/getTradId.js +0 -5
- package/config/functions/bootstrap.js +0 -48
- package/config/routes.json +0 -124
- package/controllers/comments.js +0 -215
- package/models/comment.js +0 -8
- package/models/comment.settings.json +0 -90
- package/models/report.js +0 -8
- package/models/report.settings.json +0 -41
- package/services/comments.js +0 -478
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comments Collection Type
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
info: {
|
|
7
|
+
tableName: 'plugin-comments-reports',
|
|
8
|
+
singularName: 'comment-report',
|
|
9
|
+
pluralName: 'comment-reports',
|
|
10
|
+
displayName: 'Reports',
|
|
11
|
+
description: 'Reports content type',
|
|
12
|
+
kind: 'collectionType',
|
|
13
|
+
},
|
|
14
|
+
options: {
|
|
15
|
+
draftAndPublish: false,
|
|
16
|
+
},
|
|
17
|
+
pluginOptions: {
|
|
18
|
+
'content-manager': {
|
|
19
|
+
visible: false
|
|
20
|
+
},
|
|
21
|
+
'content-type-builder': {
|
|
22
|
+
visible: false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
attributes: {
|
|
26
|
+
content: {
|
|
27
|
+
type: 'text',
|
|
28
|
+
configurable: false
|
|
29
|
+
},
|
|
30
|
+
reason: {
|
|
31
|
+
type: 'enumeration',
|
|
32
|
+
enum: [
|
|
33
|
+
'BAD_LANGUAGE',
|
|
34
|
+
'DISCRIMINATION',
|
|
35
|
+
'OTHER'
|
|
36
|
+
],
|
|
37
|
+
default: 'OTHER',
|
|
38
|
+
configurable: false,
|
|
39
|
+
required: true
|
|
40
|
+
},
|
|
41
|
+
resolved: {
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
default: false,
|
|
44
|
+
configurable: false
|
|
45
|
+
},
|
|
46
|
+
related: {
|
|
47
|
+
type: 'relation',
|
|
48
|
+
relation: 'manyToOne',
|
|
49
|
+
target: 'plugin::comments.comment',
|
|
50
|
+
inversedBy: 'reports',
|
|
51
|
+
configurable: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
package/package.json
CHANGED
|
@@ -1,41 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-comments",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "Strapi - Comments plugin",
|
|
5
5
|
"strapi": {
|
|
6
|
-
"name": "
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/VirtusLab/strapi-plugin-comments"
|
|
6
|
+
"name": "comments",
|
|
7
|
+
"description": "Comments & audience engagement",
|
|
8
|
+
"kind": "plugin"
|
|
13
9
|
},
|
|
14
10
|
"scripts": {
|
|
15
11
|
"test:unit": "jest --verbose --coverage"
|
|
16
12
|
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/VirtusLab-Open-Source/strapi-plugin-comments"
|
|
16
|
+
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"bad-words": "^3.0.
|
|
19
|
-
"lodash": "^4.17.11",
|
|
20
|
-
"react": "^16.9.0",
|
|
21
|
-
"react-dom": "^16.9.0",
|
|
22
|
-
"react-intl": "4.5.0",
|
|
23
|
-
"react-redux": "^7.0.2",
|
|
24
|
-
"react-router": "^5.0.0",
|
|
25
|
-
"react-router-dom": "^5.0.0",
|
|
26
|
-
"reactstrap": "8.4.1",
|
|
27
|
-
"redux-saga": "^0.16.0",
|
|
28
|
-
"request": "^2.83.0",
|
|
29
|
-
"strapi-helper-plugin": "3.6.0",
|
|
30
|
-
"strapi-utils": "3.6.0",
|
|
31
|
-
"uuid": "^3.1.0"
|
|
18
|
+
"bad-words": "^3.0.4"
|
|
32
19
|
},
|
|
33
20
|
"devDependencies": {
|
|
34
|
-
"
|
|
21
|
+
"codecov": "^3.7.2",
|
|
35
22
|
"jest": "^26.0.1",
|
|
36
23
|
"jest-cli": "^26.0.1",
|
|
37
|
-
"jest-styled-components": "^7.0.2"
|
|
38
|
-
"codecov": "^3.7.2"
|
|
24
|
+
"jest-styled-components": "^7.0.2"
|
|
39
25
|
},
|
|
40
26
|
"author": {
|
|
41
27
|
"name": "VirtusLab // Mateusz Ziarko",
|
|
@@ -55,7 +41,7 @@
|
|
|
55
41
|
}
|
|
56
42
|
],
|
|
57
43
|
"engines": {
|
|
58
|
-
"node": ">=
|
|
44
|
+
"node": ">=12.x. <=16.x.x",
|
|
59
45
|
"npm": ">=6.0.0"
|
|
60
46
|
},
|
|
61
47
|
"keywords": ["strapi", "plugin", "comments"],
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getPluginService } = require('./../utils/functions');
|
|
4
|
+
const { parseParams, throwError } = require('./utils/functions');
|
|
5
|
+
const _ = require('lodash');
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
|
|
9
|
+
getService(name = 'admin') {
|
|
10
|
+
return getPluginService(name);
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
async findAll(ctx) {
|
|
14
|
+
return this.getService()
|
|
15
|
+
.findAll(ctx.query);
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
async findOne(ctx) {
|
|
19
|
+
const { params = {} } = ctx;
|
|
20
|
+
const { id } = parseParams(params);
|
|
21
|
+
try {
|
|
22
|
+
return await this.getService()
|
|
23
|
+
.findOneAndThread(id);
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throwError(ctx, e);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async blockComment(ctx) {
|
|
30
|
+
const { params = {} } = ctx;
|
|
31
|
+
const { id } = parseParams(params);
|
|
32
|
+
try {
|
|
33
|
+
return await this.getService()
|
|
34
|
+
.blockComment(id, true);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
throwError(ctx, e);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
async unblockComment(ctx) {
|
|
41
|
+
const { params = {} } = ctx;
|
|
42
|
+
const { id } = parseParams(params);
|
|
43
|
+
try {
|
|
44
|
+
return await this.getService()
|
|
45
|
+
.blockComment(id, false);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
throwError(ctx, e);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
async blockCommentThread(ctx) {
|
|
52
|
+
const { params = {} } = ctx;
|
|
53
|
+
const { id } = parseParams(params);
|
|
54
|
+
try {
|
|
55
|
+
return await this.getService()
|
|
56
|
+
.blockCommentThread(id, true);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
throwError(ctx, e);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
async unblockCommentThread(ctx) {
|
|
63
|
+
const { params = {} } = ctx;
|
|
64
|
+
const { id } = parseParams(params);
|
|
65
|
+
try {
|
|
66
|
+
return await this.getService()
|
|
67
|
+
.blockCommentThread(id, false);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
throwError(ctx, e);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
async resolveAbuseReport(ctx) {
|
|
74
|
+
const { params = {} } = ctx;
|
|
75
|
+
const { id: commentId, reportId } = parseParams(params);
|
|
76
|
+
try {
|
|
77
|
+
return await this.getService()
|
|
78
|
+
.resolveAbuseReport(reportId, commentId);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
throwError(ctx, e);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
async approveComment(ctx) {
|
|
85
|
+
const { id } = parseParams(ctx.params || {});
|
|
86
|
+
try {
|
|
87
|
+
return await this.getService()
|
|
88
|
+
.approveComment(id);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
throwError(ctx, e);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
async rejectComment(ctx) {
|
|
95
|
+
const { id } = parseParams(ctx.params || {});
|
|
96
|
+
try {
|
|
97
|
+
return await this.getService()
|
|
98
|
+
.rejectComment(id);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
throwError(ctx, e);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
async config() {
|
|
105
|
+
const configRelatedContentTypes = _.get(strapi.config, ['plugins', 'comments', 'relatedContentTypes'], {});
|
|
106
|
+
const contentsTypes = this.getContentsTypes();
|
|
107
|
+
const relatedContentTypes = Object
|
|
108
|
+
.keys(configRelatedContentTypes)
|
|
109
|
+
.reduce((acc, currentKey) => {
|
|
110
|
+
const current = configRelatedContentTypes[currentKey];
|
|
111
|
+
const { key } = contentsTypes.find(content => content.value === currentKey) || {};
|
|
112
|
+
return {
|
|
113
|
+
...acc,
|
|
114
|
+
[currentKey]: {
|
|
115
|
+
...current,
|
|
116
|
+
globalName: _.snakeCase(key),
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
{},
|
|
121
|
+
);
|
|
122
|
+
return {
|
|
123
|
+
relatedContentTypes,
|
|
124
|
+
contentsTypes,
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
getContentsTypes() {
|
|
129
|
+
return Object.entries(strapi.contentTypes)
|
|
130
|
+
.filter(([, contentType]) => (
|
|
131
|
+
contentType.associations || []).some(_ => _.plugin === 'comments' && _.collection === 'comment'),
|
|
132
|
+
)
|
|
133
|
+
.reduce((acc, [, contentType]) => [
|
|
134
|
+
...acc,
|
|
135
|
+
{ key: contentType.globalName, value: contentType.collectionName }],
|
|
136
|
+
[],
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
async contentTypeName(ctx) {
|
|
141
|
+
const { params: { contentTypeName } } = ctx;
|
|
142
|
+
try {
|
|
143
|
+
const result = await this.getService()
|
|
144
|
+
.contentTypeName(contentTypeName);
|
|
145
|
+
return { list: result };
|
|
146
|
+
} catch (e) {
|
|
147
|
+
throwError(ctx, e);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getPluginService } = require('./../utils/functions');
|
|
4
|
+
const { parseParams, throwError } = require('./utils/functions');
|
|
5
|
+
const _ = require('lodash');
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
|
|
9
|
+
getService(name = 'client') {
|
|
10
|
+
return getPluginService(name);
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
async findAllFlat(ctx) {
|
|
14
|
+
const { params = {}, query } = ctx;
|
|
15
|
+
const { relation } = parseParams(params);
|
|
16
|
+
try {
|
|
17
|
+
return this.getService('common')
|
|
18
|
+
.findAllFlat({
|
|
19
|
+
...query,
|
|
20
|
+
related: relation,
|
|
21
|
+
});
|
|
22
|
+
} catch (e) {
|
|
23
|
+
throwError(ctx, e);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
async findAllInHierarchy(ctx) {
|
|
28
|
+
const { params = {}, query } = ctx;
|
|
29
|
+
const { relation } = parseParams(params);
|
|
30
|
+
try {
|
|
31
|
+
return await this.getService('common')
|
|
32
|
+
.findAllInHierarchy({
|
|
33
|
+
query: {
|
|
34
|
+
...query,
|
|
35
|
+
related: relation,
|
|
36
|
+
},
|
|
37
|
+
dropBlockedThreads: true,
|
|
38
|
+
});
|
|
39
|
+
} catch (e) {
|
|
40
|
+
throwError(ctx, e);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
async post(ctx) {
|
|
45
|
+
const { request, params = {}, state = {} } = ctx;
|
|
46
|
+
const { relation } = parseParams(params);
|
|
47
|
+
const { user } = state;
|
|
48
|
+
const { body = {} } = request;
|
|
49
|
+
try {
|
|
50
|
+
const entity = await this.getService()
|
|
51
|
+
.create(relation, body, user);
|
|
52
|
+
|
|
53
|
+
if (entity) {
|
|
54
|
+
return entity;
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {
|
|
57
|
+
throwError(ctx, e);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
async put(ctx) {
|
|
62
|
+
const { request, state, params = {} } = ctx;
|
|
63
|
+
const { body = {} } = request;
|
|
64
|
+
const { user } = state;
|
|
65
|
+
const { commentId, relation } = parseParams(params);
|
|
66
|
+
try {
|
|
67
|
+
return await this.getService()
|
|
68
|
+
.update(commentId, relation, body, user);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
throwError(ctx, e);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
async reportAbuse(ctx) {
|
|
75
|
+
const { request, state, params = {} } = ctx;
|
|
76
|
+
const { body = {} } = request;
|
|
77
|
+
if (!body.content) {
|
|
78
|
+
return ctx.badRequest(null, 'Content field is required');
|
|
79
|
+
}
|
|
80
|
+
const { user } = state;
|
|
81
|
+
const { relation, commentId } = parseParams(params);
|
|
82
|
+
try {
|
|
83
|
+
return await this.getService()
|
|
84
|
+
.reportAbuse(commentId, relation, body, user);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
throwError(ctx, e);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
async removeComment(ctx) {
|
|
91
|
+
const { params: { relationId, commentId }, query: { authorId } } = ctx;
|
|
92
|
+
if (authorId) {
|
|
93
|
+
try {
|
|
94
|
+
return await this.getService()
|
|
95
|
+
.markAsRemoved(
|
|
96
|
+
relationId,
|
|
97
|
+
commentId,
|
|
98
|
+
authorId,
|
|
99
|
+
);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
if (!e.isBoom) {
|
|
102
|
+
throwError(ctx, e);
|
|
103
|
+
}
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return ctx.badRequest('Not provided authorId');
|
|
108
|
+
},
|
|
109
|
+
};
|
|
File without changes
|
package/server/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const register = require('./register');
|
|
4
|
+
const bootstrap = require('./bootstrap');
|
|
5
|
+
const destroy = require('./destroy');
|
|
6
|
+
const config = require('./config');
|
|
7
|
+
const controllers = require('./controllers');
|
|
8
|
+
const routes = require('./routes');
|
|
9
|
+
const services = require('./services');
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
register,
|
|
13
|
+
bootstrap,
|
|
14
|
+
destroy,
|
|
15
|
+
config,
|
|
16
|
+
controllers,
|
|
17
|
+
routes,
|
|
18
|
+
services,
|
|
19
|
+
contentTypes: {},
|
|
20
|
+
policies: {},
|
|
21
|
+
middlewares: {},
|
|
22
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
{
|
|
5
|
+
method: 'GET',
|
|
6
|
+
path: '/moderate/config',
|
|
7
|
+
handler: 'admin.config',
|
|
8
|
+
config: {
|
|
9
|
+
policies: [],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
method: 'GET',
|
|
14
|
+
path: '/moderate/config/content-types/:contentTypeName',
|
|
15
|
+
handler: 'admin.contentTypeName',
|
|
16
|
+
config: {
|
|
17
|
+
policies: [],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
method: 'GET',
|
|
22
|
+
path: '/moderate/all',
|
|
23
|
+
handler: 'admin.findAll',
|
|
24
|
+
config: {
|
|
25
|
+
policies: [],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
method: 'GET',
|
|
30
|
+
path: '/moderate/single/:id',
|
|
31
|
+
handler: 'admin.findOne',
|
|
32
|
+
config: {
|
|
33
|
+
policies: [],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
method: 'PATCH',
|
|
38
|
+
path: '/moderate/single/:id/approve',
|
|
39
|
+
handler: 'admin.approveComment',
|
|
40
|
+
config: {
|
|
41
|
+
policies: [],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
method: 'PATCH',
|
|
46
|
+
path: '/moderate/single/:id/reject',
|
|
47
|
+
handler: 'admin.rejectComment',
|
|
48
|
+
config: {
|
|
49
|
+
policies: [],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
method: 'PATCH',
|
|
54
|
+
path: '/moderate/single/:id/block',
|
|
55
|
+
handler: 'admin.blockComment',
|
|
56
|
+
config: {
|
|
57
|
+
policies: [],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
method: 'PATCH',
|
|
62
|
+
path: '/moderate/single/:id/unblock',
|
|
63
|
+
handler: 'admin.unblockComment',
|
|
64
|
+
config: {
|
|
65
|
+
policies: [],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
method: 'PATCH',
|
|
70
|
+
path: '/moderate/single/:id/report/:reportId/resolve',
|
|
71
|
+
handler: 'admin.resolveAbuseReport',
|
|
72
|
+
config: {
|
|
73
|
+
policies: [],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
method: 'PATCH',
|
|
78
|
+
path: '/moderate/thread/:id/block',
|
|
79
|
+
handler: 'admin.blockCommentThread',
|
|
80
|
+
config: {
|
|
81
|
+
policies: [],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
method: 'PATCH',
|
|
86
|
+
path: '/moderate/thread/:id/unblock',
|
|
87
|
+
handler: 'admin.unblockCommentThread',
|
|
88
|
+
config: {
|
|
89
|
+
policies: [],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
{
|
|
5
|
+
method: 'GET',
|
|
6
|
+
path: '/:relation',
|
|
7
|
+
handler: 'client.findAllInHierarchy',
|
|
8
|
+
config: {
|
|
9
|
+
policies: [],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
method: 'POST',
|
|
14
|
+
path: '/:relation',
|
|
15
|
+
handler: 'client.post',
|
|
16
|
+
config: {
|
|
17
|
+
policies: [],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
method: 'GET',
|
|
22
|
+
path: '/:relation/flat',
|
|
23
|
+
handler: 'client.findAllFlat',
|
|
24
|
+
config: {
|
|
25
|
+
policies: [],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
method: 'PUT',
|
|
30
|
+
path: '/:relation/comment/:commentId',
|
|
31
|
+
handler: 'client.put',
|
|
32
|
+
config: {
|
|
33
|
+
policies: [],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
method: 'POST',
|
|
38
|
+
path: '/:relation/comment/:commentId/report-abuse',
|
|
39
|
+
handler: 'client.reportAbuse',
|
|
40
|
+
config: {
|
|
41
|
+
policies: [],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
method: 'DELETE',
|
|
46
|
+
path: '/:relationId/comment/:commentId',
|
|
47
|
+
handler: 'client.removeComment',
|
|
48
|
+
config: {
|
|
49
|
+
policies: [],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const clientRoutes = require('./client');
|
|
4
|
+
const adminRoutes = require('./admin');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
'content-api': {
|
|
8
|
+
type: 'content-api',
|
|
9
|
+
routes: clientRoutes,
|
|
10
|
+
},
|
|
11
|
+
admin: {
|
|
12
|
+
type: 'admin',
|
|
13
|
+
routes: adminRoutes,
|
|
14
|
+
},
|
|
15
|
+
};
|