strapi-plugin-comments 2.0.8 → 2.1.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/README.md +171 -127
- package/admin/src/components/ActionButton/styles.d.ts +2 -0
- package/admin/src/components/ActionButton/styles.js +13 -8
- package/admin/src/components/ConfirmationDialog/index.d.ts +26 -0
- package/admin/src/components/ConfirmationDialog/index.js +36 -55
- package/admin/src/components/DiscussionStatus/index.d.ts +9 -0
- package/admin/src/components/DiscussionStatus/index.js +22 -31
- package/admin/src/components/DiscussionThread/index.d.ts +16 -0
- package/admin/src/components/DiscussionThread/index.js +39 -56
- package/admin/src/components/DiscussionThreadItem/index.d.ts +9 -0
- package/admin/src/components/DiscussionThreadItem/index.js +28 -52
- package/admin/src/components/DiscussionThreadItem/styles.d.ts +4 -0
- package/admin/src/components/DiscussionThreadItem/styles.js +16 -11
- package/admin/src/components/DiscussionThreadItemActions/index.d.ts +19 -0
- package/admin/src/components/DiscussionThreadItemActions/index.js +121 -158
- package/admin/src/components/DiscussionThreadItemActions/styles.d.ts +2 -0
- package/admin/src/components/DiscussionThreadItemActions/styles.js +13 -7
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.d.ts +17 -0
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +38 -48
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.d.ts +2 -0
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.js +12 -6
- package/admin/src/components/DiscussionThreadItemFooter/index.d.ts +16 -0
- package/admin/src/components/DiscussionThreadItemFooter/index.js +35 -42
- package/admin/src/components/DiscussionThreadItemFooter/styles.d.ts +3 -0
- package/admin/src/components/DiscussionThreadItemFooter/styles.js +17 -12
- package/admin/src/components/DiscussionThreadItemReviewAction/index.d.ts +30 -0
- package/admin/src/components/DiscussionThreadItemReviewAction/index.js +77 -91
- package/admin/src/components/FormSwitch/index.d.ts +7 -0
- package/admin/src/components/FormSwitch/index.js +15 -18
- package/admin/src/components/FormSwitch/styles.d.ts +2 -0
- package/admin/src/components/FormSwitch/styles.js +14 -8
- package/admin/src/components/IconButton/styles.d.ts +2 -0
- package/admin/src/components/IconButton/styles.js +16 -9
- package/admin/src/components/Initializer/index.d.ts +5 -0
- package/admin/src/components/Initializer/index.js +12 -24
- package/admin/src/components/LoadingIndicatorOverlay/index.d.ts +3 -0
- package/admin/src/components/LoadingIndicatorOverlay/index.js +12 -15
- package/admin/src/components/LoadingIndicatorOverlay/styles.d.ts +3 -0
- package/admin/src/components/LoadingIndicatorOverlay/styles.js +22 -17
- package/admin/src/components/Nav/index.d.ts +7 -0
- package/admin/src/components/Nav/index.js +25 -48
- package/admin/src/components/PluginIcon/index.d.ts +3 -0
- package/admin/src/components/PluginIcon/index.js +10 -12
- package/admin/src/components/ReportsReviewModal/index.d.ts +21 -0
- package/admin/src/components/ReportsReviewModal/index.js +31 -46
- package/admin/src/components/ReportsReviewTable/index.d.ts +21 -0
- package/admin/src/components/ReportsReviewTable/index.js +120 -140
- package/admin/src/components/StatusBadge/index.d.ts +7 -0
- package/admin/src/components/StatusBadge/index.js +12 -17
- package/admin/src/components/StatusBadge/styles.d.ts +2 -0
- package/admin/src/components/StatusBadge/styles.js +19 -13
- package/admin/src/components/TableFilters/index.d.ts +10 -0
- package/admin/src/components/TableFilters/index.js +52 -49
- package/admin/src/components/TablePagination/index.d.ts +17 -0
- package/admin/src/components/TablePagination/index.js +27 -29
- package/admin/src/components/icons/comments.d.ts +6 -0
- package/admin/src/components/icons/comments.js +11 -8
- package/admin/src/components/icons/index.d.ts +6 -0
- package/admin/src/components/icons/index.js +15 -6
- package/admin/src/components/icons/lock.d.ts +7 -0
- package/admin/src/components/icons/lock.js +11 -21
- package/admin/src/components/icons/review.d.ts +7 -0
- package/admin/src/components/icons/review.js +11 -17
- package/admin/src/components/icons/unlock.d.ts +7 -0
- package/admin/src/components/icons/unlock.js +11 -19
- package/admin/src/hooks/useConfig.d.ts +8 -0
- package/admin/src/hooks/useConfig.js +40 -45
- package/admin/src/index.d.ts +7 -0
- package/admin/src/index.js +98 -92
- package/admin/src/pages/App/index.d.ts +4 -0
- package/admin/src/pages/App/index.js +43 -67
- package/admin/src/pages/App/reducer/actions.d.ts +8 -0
- package/admin/src/pages/App/reducer/actions.js +11 -7
- package/admin/src/pages/App/reducer/constants.d.ts +4 -0
- package/admin/src/pages/App/reducer/constants.js +7 -4
- package/admin/src/pages/App/reducer/index.d.ts +9 -0
- package/admin/src/pages/App/reducer/index.js +24 -22
- package/admin/src/pages/App/reducer/init.d.ts +3 -0
- package/admin/src/pages/App/reducer/init.js +6 -4
- package/admin/src/pages/App/reducer/selectors.d.ts +6 -0
- package/admin/src/pages/App/reducer/selectors.js +17 -34
- package/admin/src/pages/App/utils/api.d.ts +2 -0
- package/admin/src/pages/App/utils/api.js +14 -11
- package/admin/src/pages/ComingSoonPage/index.d.ts +3 -0
- package/admin/src/pages/ComingSoonPage/index.js +42 -24
- package/admin/src/pages/Details/components/DetailsEntity/index.d.ts +18 -0
- package/admin/src/pages/Details/components/DetailsEntity/index.js +49 -77
- package/admin/src/pages/Details/components/DetailsFilters/index.d.ts +12 -0
- package/admin/src/pages/Details/components/DetailsFilters/index.js +19 -26
- package/admin/src/pages/Details/components/DetailsFilters/styles.d.ts +2 -0
- package/admin/src/pages/Details/components/DetailsFilters/styles.js +14 -8
- package/admin/src/pages/Details/index.d.ts +4 -0
- package/admin/src/pages/Details/index.js +94 -133
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.d.ts +20 -0
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +128 -139
- package/admin/src/pages/Discover/components/DiscoverTableRow/styles.d.ts +2 -0
- package/admin/src/pages/Discover/components/DiscoverTableRow/styles.js +14 -8
- package/admin/src/pages/Discover/index.d.ts +4 -0
- package/admin/src/pages/Discover/index.js +129 -170
- package/admin/src/pages/Discover/utils/api.d.ts +2 -0
- package/admin/src/pages/Discover/utils/api.js +15 -13
- package/admin/src/pages/Discover/utils/filtersSchema.d.ts +11 -0
- package/admin/src/pages/Discover/utils/filtersSchema.js +8 -6
- package/admin/src/pages/Settings/components/RestartAlert/styles.d.ts +2 -0
- package/admin/src/pages/Settings/components/RestartAlert/styles.js +14 -8
- package/admin/src/pages/Settings/index.d.ts +3 -0
- package/admin/src/pages/Settings/index.js +225 -391
- package/admin/src/pages/Settings/utils/api.d.ts +7 -0
- package/admin/src/pages/Settings/utils/api.js +60 -55
- package/admin/src/pages/utils/api.d.ts +12 -0
- package/admin/src/pages/utils/api.js +58 -53
- package/admin/src/permissions.d.ts +28 -0
- package/admin/src/permissions.js +31 -17
- package/admin/src/pluginId.d.ts +2 -0
- package/admin/src/pluginId.js +29 -5
- package/admin/src/reducers.d.ts +7 -0
- package/admin/src/reducers.js +10 -6
- package/admin/src/translations/en.json +131 -130
- package/admin/src/translations/fr.json +1 -1
- package/admin/src/translations/pt-BR.json +132 -0
- package/admin/src/utils/axiosInstance.d.ts +3 -0
- package/admin/src/utils/axiosInstance.js +21 -27
- package/admin/src/utils/constants.d.ts +25 -0
- package/admin/src/utils/constants.js +23 -22
- package/admin/src/utils/getApiUrl.d.ts +3 -0
- package/admin/src/utils/getApiUrl.js +6 -5
- package/admin/src/utils/getMessage.d.ts +4 -0
- package/admin/src/utils/getMessage.js +15 -15
- package/admin/src/utils/getRelatedGroups.d.ts +4 -0
- package/admin/src/utils/getRelatedGroups.js +5 -3
- package/admin/src/utils/getUrl.d.ts +3 -0
- package/admin/src/utils/getUrl.js +6 -5
- package/admin/src/utils/handleAPIError.d.ts +4 -0
- package/admin/src/utils/handleAPIError.js +12 -11
- package/admin/src/utils/index.d.ts +12 -0
- package/admin/src/utils/index.js +29 -11
- package/admin/src/utils/parseRegExp.d.ts +6 -0
- package/admin/src/utils/parseRegExp.js +6 -5
- package/admin/src/utils/renderEntryTitle.d.ts +4 -0
- package/admin/src/utils/renderEntryTitle.js +11 -12
- package/admin/src/utils/renderInitials.d.ts +3 -0
- package/admin/src/utils/renderInitials.js +10 -5
- package/admin/src/utils/resolveCommentStatus.d.ts +4 -0
- package/admin/src/utils/resolveCommentStatus.js +17 -21
- package/admin/src/utils/resolveCommentStatusColor.d.ts +4 -0
- package/admin/src/utils/resolveCommentStatusColor.js +19 -19
- package/content-types/comment.d.ts +91 -0
- package/content-types/comment.js +87 -88
- package/content-types/index.d.ts +143 -0
- package/content-types/index.js +15 -10
- package/content-types/report.d.ts +48 -0
- package/content-types/report.js +44 -49
- package/package.json +24 -19
- package/permissions.d.ts +18 -0
- package/permissions.js +12 -13
- package/server/bootstrap.d.ts +4 -0
- package/server/bootstrap.js +56 -62
- package/server/config/index.d.ts +4 -0
- package/server/config/index.js +17 -15
- package/server/controllers/admin.d.ts +4 -0
- package/server/controllers/admin.js +134 -167
- package/server/controllers/client.d.ts +4 -0
- package/server/controllers/client.js +104 -115
- package/server/controllers/index.d.ts +6 -0
- package/server/controllers/index.js +12 -8
- package/server/controllers/utils/functions.d.ts +7 -0
- package/server/controllers/utils/functions.js +22 -17
- package/server/controllers/utils/parsers.d.ts +15 -0
- package/server/controllers/utils/parsers.js +17 -17
- package/server/destroy.d.ts +3 -0
- package/server/destroy.js +3 -4
- package/server/graphql/index.d.ts +4 -0
- package/server/graphql/index.js +27 -25
- package/server/graphql/mutations/createAbuseReport.d.ts +11 -0
- package/server/graphql/mutations/createAbuseReport.js +22 -24
- package/server/graphql/mutations/createComment.d.ts +14 -0
- package/server/graphql/mutations/createComment.js +22 -24
- package/server/graphql/mutations/index.d.ts +4 -0
- package/server/graphql/mutations/index.js +24 -19
- package/server/graphql/mutations/removeComment.d.ts +11 -0
- package/server/graphql/mutations/removeComment.js +22 -24
- package/server/graphql/mutations/updateComment.d.ts +11 -0
- package/server/graphql/mutations/updateComment.js +22 -24
- package/server/graphql/queries/findAllFlat.d.ts +19 -0
- package/server/graphql/queries/findAllFlat.js +31 -30
- package/server/graphql/queries/findAllInHierarchy.d.ts +18 -0
- package/server/graphql/queries/findAllInHierarchy.js +26 -30
- package/server/graphql/queries/index.d.ts +4 -0
- package/server/graphql/queries/index.js +20 -17
- package/server/graphql/resolvers-config.d.ts +23 -0
- package/server/graphql/resolvers-config.js +11 -11
- package/server/graphql/types/comment-author.d.ts +4 -0
- package/server/graphql/types/comment-author.js +10 -8
- package/server/graphql/types/comment-nested.d.ts +4 -0
- package/server/graphql/types/comment-nested.js +17 -15
- package/server/graphql/types/comment.d.ts +4 -0
- package/server/graphql/types/comment.js +16 -14
- package/server/graphql/types/create-comment-author.d.ts +4 -0
- package/server/graphql/types/create-comment-author.js +10 -8
- package/server/graphql/types/create-comment.d.ts +4 -0
- package/server/graphql/types/create-comment.js +10 -8
- package/server/graphql/types/create-report.d.ts +4 -0
- package/server/graphql/types/create-report.js +10 -8
- package/server/graphql/types/id.d.ts +4 -0
- package/server/graphql/types/id.js +24 -23
- package/server/graphql/types/identify-comment-author.d.ts +4 -0
- package/server/graphql/types/identify-comment-author.js +7 -5
- package/server/graphql/types/index.d.ts +4 -0
- package/server/graphql/types/index.js +36 -17
- package/server/graphql/types/remove-comment.d.ts +4 -0
- package/server/graphql/types/remove-comment.js +9 -7
- package/server/graphql/types/report-reason.d.ts +4 -0
- package/server/graphql/types/report-reason.js +10 -8
- package/server/graphql/types/report.d.ts +4 -0
- package/server/graphql/types/report.js +12 -10
- package/server/graphql/types/response-find-all.d.ts +4 -0
- package/server/graphql/types/response-find-all.js +8 -6
- package/server/graphql/types/response-meta.d.ts +4 -0
- package/server/graphql/types/response-meta.js +7 -5
- package/server/graphql/types/response-pagination.d.ts +4 -0
- package/server/graphql/types/response-pagination.js +12 -10
- package/server/graphql/types/update-comment.d.ts +4 -0
- package/server/graphql/types/update-comment.js +10 -8
- package/server/index.d.ts +26 -0
- package/server/index.js +24 -21
- package/server/register.d.ts +3 -0
- package/server/register.js +3 -4
- package/server/routes/admin.d.ts +4 -0
- package/server/routes/admin.js +103 -109
- package/server/routes/client.d.ts +4 -0
- package/server/routes/client.js +48 -46
- package/server/routes/index.d.ts +11 -0
- package/server/routes/index.js +18 -14
- package/server/services/admin.d.ts +5 -0
- package/server/services/admin.js +126 -158
- package/server/services/client.d.ts +5 -0
- package/server/services/client.js +135 -151
- package/server/services/common.d.ts +5 -0
- package/server/services/common.js +165 -194
- package/server/services/graphql.d.ts +5 -0
- package/server/services/graphql.js +117 -182
- package/server/services/index.d.ts +8 -0
- package/server/services/index.js +15 -12
- package/server/services/utils/functions.d.ts +13 -0
- package/server/services/utils/functions.js +100 -109
- package/server/utils/constants.d.ts +9 -0
- package/server/utils/constants.js +19 -23
- package/server/utils/error.d.ts +19 -0
- package/server/utils/error.js +23 -18
- package/server/utils/functions.d.ts +6 -0
- package/server/utils/functions.js +35 -18
- package/strapi-admin.d.ts +3 -0
- package/strapi-admin.js +8 -3
- package/strapi-server.d.ts +177 -0
- package/strapi-server.js +43 -46
- package/tsconfig.tsbuildinfo +1 -0
- package/types/contentTypes.d.ts +44 -0
- package/types/contentTypes.js +3 -0
- package/.husky/pre-commit +0 -4
- package/LICENSE.md +0 -7
- package/__mocks__/initSetup.js +0 -108
- package/jest.config.js +0 -7
- package/server/controllers/utils/__tests__/functions.test.js +0 -43
- package/server/controllers/utils/__tests__/parsers.test.js +0 -94
- package/server/services/__tests__/common.test.js +0 -399
- package/server/services/utils/__tests__/functions.test.js +0 -53
- package/server/utils/__tests__/functions.test.js +0 -17
|
@@ -1,168 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
async rejectComment(ctx) {
|
|
137
|
-
const { id } = parseParams(ctx.params || {});
|
|
138
|
-
try {
|
|
139
|
-
return await this.getService()
|
|
140
|
-
.rejectComment(id);
|
|
141
|
-
} catch (e) {
|
|
142
|
-
throwError(ctx, e);
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
getContentsTypes() {
|
|
147
|
-
return Object.entries(strapi.contentTypes)
|
|
148
|
-
.filter(([, contentType]) => (
|
|
149
|
-
contentType.associations || []).some(_ => _.plugin === 'comments' && _.collection === 'comment'),
|
|
150
|
-
)
|
|
151
|
-
.reduce((acc, [, contentType]) => [
|
|
152
|
-
...acc,
|
|
153
|
-
{ key: contentType.globalName, value: contentType.collectionName }],
|
|
154
|
-
[],
|
|
155
|
-
);
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
async contentTypeName(ctx) {
|
|
159
|
-
const { params: { contentTypeName } } = ctx;
|
|
160
|
-
try {
|
|
161
|
-
const result = await this.getService()
|
|
162
|
-
.contentTypeName(contentTypeName);
|
|
163
|
-
return { list: result };
|
|
164
|
-
} catch (e) {
|
|
165
|
-
throwError(ctx, e);
|
|
166
|
-
}
|
|
167
|
-
},
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const functions_1 = require("./../utils/functions");
|
|
4
|
+
const functions_2 = require("./utils/functions");
|
|
5
|
+
const controllers = {
|
|
6
|
+
getService(name = "admin") {
|
|
7
|
+
return (0, functions_1.getPluginService)(name);
|
|
8
|
+
},
|
|
9
|
+
async config(ctx) {
|
|
10
|
+
try {
|
|
11
|
+
return await this.getService().config();
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
async settingsConfig(ctx) {
|
|
18
|
+
try {
|
|
19
|
+
return this.getService().config(true);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
async settingsUpdateConfig(ctx) {
|
|
26
|
+
try {
|
|
27
|
+
const { request: { body }, } = ctx;
|
|
28
|
+
(0, functions_1.assertNotEmpty)(body);
|
|
29
|
+
return this.getService().updateConfig(body);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
async settingsRestoreConfig(ctx) {
|
|
36
|
+
try {
|
|
37
|
+
return this.getService().restoreConfig();
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
async settingsRestart(ctx) {
|
|
44
|
+
try {
|
|
45
|
+
await this.getService().restart();
|
|
46
|
+
return ctx.send({ status: 200 });
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
async findAll(ctx) {
|
|
53
|
+
return this.getService().findAll(ctx.query);
|
|
54
|
+
},
|
|
55
|
+
async findOne(ctx) {
|
|
56
|
+
const { params = {}, query } = ctx;
|
|
57
|
+
const { id } = (0, functions_2.parseParams)(params);
|
|
58
|
+
try {
|
|
59
|
+
return await this.getService().findOneAndThread(id, query);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
async blockComment(ctx) {
|
|
66
|
+
const { params = {} } = ctx;
|
|
67
|
+
const { id } = (0, functions_2.parseParams)(params);
|
|
68
|
+
try {
|
|
69
|
+
return await this.getService().blockComment(id, true);
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
async unblockComment(ctx) {
|
|
76
|
+
const { params = {} } = ctx;
|
|
77
|
+
const { id } = (0, functions_2.parseParams)(params);
|
|
78
|
+
try {
|
|
79
|
+
return await this.getService().blockComment(id, false);
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
async blockCommentThread(ctx) {
|
|
86
|
+
const { params = {} } = ctx;
|
|
87
|
+
const { id } = (0, functions_2.parseParams)(params);
|
|
88
|
+
try {
|
|
89
|
+
return await this.getService().blockCommentThread(id, true);
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
async unblockCommentThread(ctx) {
|
|
96
|
+
const { params = {} } = ctx;
|
|
97
|
+
const { id } = (0, functions_2.parseParams)(params);
|
|
98
|
+
try {
|
|
99
|
+
return await this.getService().blockCommentThread(id, false);
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
async resolveAbuseReport(ctx) {
|
|
106
|
+
const { params = {} } = ctx;
|
|
107
|
+
const { id: commentId, reportId } = (0, functions_2.parseParams)(params);
|
|
108
|
+
try {
|
|
109
|
+
return await this.getService().resolveAbuseReport(reportId, commentId);
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
async approveComment(ctx) {
|
|
116
|
+
const { id } = (0, functions_2.parseParams)(ctx.params || {});
|
|
117
|
+
try {
|
|
118
|
+
return await this.getService().approveComment(id);
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
async rejectComment(ctx) {
|
|
125
|
+
const { id } = (0, functions_2.parseParams)(ctx.params || {});
|
|
126
|
+
try {
|
|
127
|
+
return await this.getService().rejectComment(id);
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
168
133
|
};
|
|
134
|
+
exports.default = controllers;
|
|
135
|
+
//# sourceMappingURL=admin.js.map
|
|
@@ -1,117 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const { sort: querySort, pagination: queryPagination, ...filterQuery } = query || {};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
console.log(filterQuery);
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
return this.getService('common')
|
|
24
|
-
.findAllFlat(flatInput(relation, filterQuery, sort || querySort, pagination || queryPagination));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
throwError(ctx, e);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
async findAllInHierarchy(ctx) {
|
|
31
|
-
const { params = {}, query, sort } = ctx;
|
|
32
|
-
const { relation } = parseParams(params);
|
|
33
|
-
|
|
34
|
-
const { sort: querySort, ...filterQuery } = query || {};
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
return await this.getService('common')
|
|
38
|
-
.findAllInHierarchy({
|
|
39
|
-
...flatInput(relation, filterQuery, sort || querySort),
|
|
40
|
-
dropBlockedThreads: true,
|
|
41
|
-
});
|
|
42
|
-
} catch (e) {
|
|
43
|
-
throwError(ctx, e);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
async post(ctx) {
|
|
48
|
-
const { request, params = {}, state = {} } = ctx;
|
|
49
|
-
const { relation } = parseParams(params);
|
|
50
|
-
const { user } = state;
|
|
51
|
-
const { body = {} } = request;
|
|
52
|
-
try {
|
|
53
|
-
const entity = await this.getService()
|
|
54
|
-
.create(relation, body, user);
|
|
55
|
-
|
|
56
|
-
if (entity) {
|
|
57
|
-
return entity;
|
|
58
|
-
}
|
|
59
|
-
} catch (e) {
|
|
60
|
-
throwError(ctx, e);
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
async put(ctx) {
|
|
65
|
-
const { request, state, params = {} } = ctx;
|
|
66
|
-
const { body = {} } = request;
|
|
67
|
-
const { user } = state;
|
|
68
|
-
const { commentId, relation } = parseParams(params);
|
|
69
|
-
try {
|
|
70
|
-
return await this.getService()
|
|
71
|
-
.update(commentId, relation, body, user);
|
|
72
|
-
} catch (e) {
|
|
73
|
-
throwError(ctx, e);
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
async reportAbuse(ctx) {
|
|
78
|
-
const { request, state, params = {} } = ctx;
|
|
79
|
-
const { body = {} } = request;
|
|
80
|
-
if (!body.content) {
|
|
81
|
-
return ctx.badRequest(null, 'Content field is required');
|
|
82
|
-
}
|
|
83
|
-
const { user } = state;
|
|
84
|
-
const { relation, commentId } = parseParams(params);
|
|
85
|
-
try {
|
|
86
|
-
return await this.getService()
|
|
87
|
-
.reportAbuse(commentId, relation, body, user);
|
|
88
|
-
} catch (e) {
|
|
89
|
-
throwError(ctx, e);
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
async removeComment(ctx) {
|
|
94
|
-
const {
|
|
95
|
-
params: { relationId, commentId },
|
|
96
|
-
query: { authorId },
|
|
97
|
-
state: { user },
|
|
98
|
-
} = ctx;
|
|
99
|
-
if (authorId || user?.id) {
|
|
100
|
-
try {
|
|
101
|
-
return await this.getService()
|
|
102
|
-
.markAsRemoved(
|
|
103
|
-
commentId,
|
|
104
|
-
relationId,
|
|
105
|
-
authorId,
|
|
106
|
-
user
|
|
107
|
-
);
|
|
108
|
-
} catch (e) {
|
|
109
|
-
if (!e.isBoom) {
|
|
110
|
-
throwError(ctx, e);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const functions_1 = require("./../utils/functions");
|
|
4
|
+
const functions_2 = require("./utils/functions");
|
|
5
|
+
const parsers_1 = require("./utils/parsers");
|
|
6
|
+
const controllers = {
|
|
7
|
+
getService(name = "client") {
|
|
8
|
+
return (0, functions_1.getPluginService)(name);
|
|
9
|
+
},
|
|
10
|
+
async findAllFlat(ctx) {
|
|
11
|
+
const { params = {}, query, sort, pagination } = ctx;
|
|
12
|
+
const { relation } = (0, functions_2.parseParams)(params);
|
|
13
|
+
const { sort: querySort, pagination: queryPagination, ...filterQuery } = query || {};
|
|
14
|
+
try {
|
|
15
|
+
(0, functions_1.assertParamsPresent)(params, ["relation"]);
|
|
16
|
+
return this.getService("common").findAllFlat((0, parsers_1.flatInput)(relation, filterQuery, sort || querySort, pagination || queryPagination));
|
|
111
17
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
18
|
+
catch (e) {
|
|
19
|
+
(0, functions_2.throwError)(ctx, e);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
async findAllInHierarchy(ctx) {
|
|
23
|
+
const { params = {}, query, sort } = ctx;
|
|
24
|
+
const { relation } = (0, functions_2.parseParams)(params);
|
|
25
|
+
const { sort: querySort, ...filterQuery } = query || {};
|
|
26
|
+
try {
|
|
27
|
+
(0, functions_1.assertParamsPresent)(params, ["relation"]);
|
|
28
|
+
return await this.getService("common").findAllInHierarchy({
|
|
29
|
+
...(0, parsers_1.flatInput)(relation, filterQuery, sort || querySort),
|
|
30
|
+
dropBlockedThreads: true,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
(0, functions_2.throwError)(ctx, e);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
async post(ctx) {
|
|
38
|
+
const { request, params = {}, state = {} } = ctx;
|
|
39
|
+
const { relation } = (0, functions_2.parseParams)(params);
|
|
40
|
+
const { user } = state;
|
|
41
|
+
const { body = {} } = request;
|
|
42
|
+
try {
|
|
43
|
+
(0, functions_1.assertParamsPresent)(params, ["relation"]);
|
|
44
|
+
(0, functions_1.assertNotEmpty)(body);
|
|
45
|
+
const entity = await this.getService().create(relation, body, user);
|
|
46
|
+
if (entity) {
|
|
47
|
+
return entity;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
(0, functions_2.throwError)(ctx, e);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
async put(ctx) {
|
|
55
|
+
const { request, state, params = {} } = ctx;
|
|
56
|
+
const { body = {} } = request;
|
|
57
|
+
const { user } = state;
|
|
58
|
+
const { commentId, relation } = (0, functions_2.parseParams)(params);
|
|
59
|
+
try {
|
|
60
|
+
(0, functions_1.assertParamsPresent)(params, ["commentId", "relation"]);
|
|
61
|
+
(0, functions_1.assertNotEmpty)(body);
|
|
62
|
+
return await this.getService().update(commentId, relation, body, user);
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
(0, functions_2.throwError)(ctx, e);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
async reportAbuse(ctx) {
|
|
69
|
+
const { request, state, params = {} } = ctx;
|
|
70
|
+
const { body = {} } = request;
|
|
71
|
+
(0, functions_1.assertNotEmpty)(body);
|
|
72
|
+
if (!body.content) {
|
|
73
|
+
return ctx.badRequest(null, "Content field is required");
|
|
74
|
+
}
|
|
75
|
+
const { user } = state;
|
|
76
|
+
const { relation, commentId } = (0, functions_2.parseParams)(params);
|
|
77
|
+
try {
|
|
78
|
+
(0, functions_1.assertParamsPresent)(params, ["commentId", "relation"]);
|
|
79
|
+
return await this.getService().reportAbuse(commentId, relation, body, user);
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
(0, functions_2.throwError)(ctx, e);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
async removeComment(ctx) {
|
|
86
|
+
const { params, query, state: { user }, } = ctx;
|
|
87
|
+
const { relationId, commentId } = (0, functions_2.parseParams)(params);
|
|
88
|
+
const { authorId } = (0, functions_2.parseParams)(query);
|
|
89
|
+
try {
|
|
90
|
+
(0, functions_1.assertParamsPresent)(params, ["commentId", "relationId"]);
|
|
91
|
+
(0, functions_1.assertParamsPresent)(query, ["authorId"]);
|
|
92
|
+
if (authorId || user?.id) {
|
|
93
|
+
return await this.getService().markAsRemoved(commentId, relationId, authorId, user);
|
|
94
|
+
}
|
|
95
|
+
return ctx.badRequest("Not provided authorId");
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
if (!e.isBoom) {
|
|
99
|
+
(0, functions_2.throwError)(ctx, e);
|
|
100
|
+
}
|
|
101
|
+
throw e;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
117
104
|
};
|
|
105
|
+
exports.default = controllers;
|
|
106
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const clientController = require('./client');
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
admin: adminController,
|
|
8
|
-
client: clientController,
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
4
|
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const admin_1 = __importDefault(require("./admin"));
|
|
7
|
+
const client_1 = __importDefault(require("./client"));
|
|
8
|
+
const controllers = {
|
|
9
|
+
admin: admin_1.default,
|
|
10
|
+
client: client_1.default,
|
|
11
|
+
};
|
|
12
|
+
exports.default = controllers;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Id, StringMap, StrapiRequestContext } from "strapi-typed";
|
|
2
|
+
import PluginError from "../../utils/error";
|
|
3
|
+
declare type ParseResponse = StringMap<string | number | Id>;
|
|
4
|
+
export declare const parseParams: (params: StringMap<string | number>) => ParseResponse;
|
|
5
|
+
export declare const throwError: <T extends {} = never>(ctx: StrapiRequestContext<T, {}>, e: PluginError | Error | unknown) => PluginError | Error | unknown | never;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.throwError = exports.parseParams = void 0;
|
|
7
|
+
const error_1 = __importDefault(require("../../utils/error"));
|
|
8
|
+
const parseParams = (params) => Object.keys(params).reduce((prev, curr) => {
|
|
9
|
+
const value = params[curr];
|
|
10
|
+
const parsedValue = Number(value);
|
|
11
|
+
return {
|
|
12
|
+
...prev,
|
|
13
|
+
[curr]: isNaN(parsedValue) ? value : parsedValue,
|
|
14
|
+
};
|
|
15
|
+
}, {});
|
|
16
|
+
exports.parseParams = parseParams;
|
|
17
|
+
const throwError = (ctx, e) => {
|
|
18
|
+
if (e instanceof error_1.default) {
|
|
19
|
+
return ctx.throw(e.status, JSON.stringify(e));
|
|
16
20
|
}
|
|
17
|
-
|
|
18
|
-
},
|
|
21
|
+
return e;
|
|
19
22
|
};
|
|
23
|
+
exports.throwError = throwError;
|
|
24
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Id } from "strapi-typed";
|
|
2
|
+
import { ToBeFixed } from "../../../types";
|
|
3
|
+
export declare const flatInput: (relation: Id, query: ToBeFixed, sort: ToBeFixed, pagination?: ToBeFixed) => {
|
|
4
|
+
query: any;
|
|
5
|
+
populate: {
|
|
6
|
+
threadOf: {
|
|
7
|
+
populate: {
|
|
8
|
+
authorUser: boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
pagination: any;
|
|
13
|
+
sort: any;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=parsers.d.ts.map
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flatInput = void 0;
|
|
4
|
+
const flatInput = (relation, query, sort, pagination) => {
|
|
5
|
+
const filters = query?.filters || query;
|
|
6
|
+
const orOperator = (filters?.$or || []).filter((_) => !Object.keys(_).includes("removed"));
|
|
7
|
+
return {
|
|
8
|
+
query: {
|
|
9
9
|
...filters,
|
|
10
10
|
$or: [...orOperator, { removed: { $null: true } }, { removed: false }],
|
|
11
11
|
related: relation,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
},
|
|
13
|
+
populate: {
|
|
14
14
|
threadOf: {
|
|
15
|
-
|
|
15
|
+
populate: { authorUser: true },
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
|
|
17
|
+
},
|
|
18
|
+
pagination,
|
|
19
|
+
sort,
|
|
20
|
+
};
|
|
23
21
|
};
|
|
22
|
+
exports.flatInput = flatInput;
|
|
23
|
+
//# sourceMappingURL=parsers.js.map
|