strapi-plugin-comments 2.0.10 → 2.1.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 +204 -124
- package/admin/src/components/ActionButton/styles.d.ts +2 -0
- package/admin/src/components/ActionButton/styles.js +13 -8
- package/admin/src/components/Avatar/index.d.ts +12 -0
- package/admin/src/components/Avatar/index.js +26 -0
- 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 +34 -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 -131
- package/admin/src/translations/fr.json +132 -1
- package/admin/src/translations/pt-BR.json +130 -130
- 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 +120 -112
- 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 +10 -0
- package/server/controllers/utils/parsers.js +47 -19
- 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 +36 -34
- package/server/graphql/queries/findAllInHierarchy.d.ts +17 -0
- package/server/graphql/queries/findAllInHierarchy.js +30 -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 +84 -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 +134 -161
- package/server/services/client.d.ts +5 -0
- package/server/services/client.js +164 -168
- package/server/services/common.d.ts +5 -0
- package/server/services/common.js +192 -202
- 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 +105 -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 +48 -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
package/server/services/admin.js
CHANGED
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Comments Plugin - Moderation services
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
module.exports = ({ strapi }) => ({
|
|
18
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const functions_1 = require("./../utils/functions");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const error_1 = __importDefault(require("./../utils/error"));
|
|
8
|
+
const functions_2 = require("./utils/functions");
|
|
9
|
+
const constants_1 = require("./../utils/constants");
|
|
10
|
+
const DEFAULT_AUTHOR_POPULATE = { avatar: true };
|
|
11
|
+
module.exports = ({ strapi }) => ({
|
|
19
12
|
getCommonService() {
|
|
20
|
-
return getPluginService(
|
|
13
|
+
return (0, functions_1.getPluginService)("common");
|
|
21
14
|
},
|
|
22
|
-
|
|
23
|
-
// Config
|
|
24
15
|
async config(viaSettingsPage = false) {
|
|
25
16
|
const pluginStore = await this.getCommonService().getPluginStore();
|
|
26
|
-
const config = await pluginStore.get({
|
|
17
|
+
const config = await pluginStore.get({
|
|
18
|
+
key: "config",
|
|
19
|
+
});
|
|
27
20
|
const additionalConfiguration = {
|
|
28
|
-
regex: Object.keys(REGEX).reduce((prev, curr) => ({
|
|
21
|
+
regex: Object.keys(constants_1.REGEX).reduce((prev, curr) => ({
|
|
29
22
|
...prev,
|
|
30
|
-
[curr]: REGEX[curr].toString(),
|
|
23
|
+
[curr]: constants_1.REGEX[curr].toString(),
|
|
31
24
|
}), {}),
|
|
32
25
|
};
|
|
33
|
-
|
|
34
|
-
const isGQLPluginEnabled = !isNil(strapi.plugin(
|
|
35
|
-
|
|
26
|
+
const getConfigProp = (key) => this.getCommonService().getLocalConfig(key);
|
|
27
|
+
const isGQLPluginEnabled = !(0, lodash_1.isNil)(strapi.plugin("graphql"));
|
|
36
28
|
if (config) {
|
|
37
29
|
return {
|
|
38
30
|
...config,
|
|
@@ -40,20 +32,18 @@ const { APPROVAL_STATUS, REGEX } = require('./../utils/constants')
|
|
|
40
32
|
isGQLPluginEnabled: viaSettingsPage ? isGQLPluginEnabled : undefined,
|
|
41
33
|
};
|
|
42
34
|
}
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const reportReasons = this.getCommonService().getLocalConfig('reportReasons');
|
|
35
|
+
const entryLabel = getConfigProp("entryLabel");
|
|
36
|
+
const approvalFlow = getConfigProp("approvalFlow");
|
|
37
|
+
const reportReasons = getConfigProp("reportReasons");
|
|
47
38
|
const result = {
|
|
48
39
|
entryLabel,
|
|
49
40
|
approvalFlow,
|
|
50
41
|
reportReasons,
|
|
51
42
|
...additionalConfiguration,
|
|
52
43
|
};
|
|
53
|
-
|
|
54
44
|
if (viaSettingsPage) {
|
|
55
|
-
const enabledCollections =
|
|
56
|
-
const moderatorRoles =
|
|
45
|
+
const enabledCollections = getConfigProp("enabledCollections");
|
|
46
|
+
const moderatorRoles = getConfigProp("moderatorRoles");
|
|
57
47
|
return {
|
|
58
48
|
...result,
|
|
59
49
|
enabledCollections,
|
|
@@ -61,49 +51,36 @@ const { APPROVAL_STATUS, REGEX } = require('./../utils/constants')
|
|
|
61
51
|
isGQLPluginEnabled,
|
|
62
52
|
};
|
|
63
53
|
}
|
|
64
|
-
|
|
65
54
|
return result;
|
|
66
55
|
},
|
|
67
|
-
|
|
68
56
|
async updateConfig(body) {
|
|
69
57
|
const pluginStore = await this.getCommonService().getPluginStore();
|
|
70
|
-
|
|
71
|
-
await pluginStore.set({ key: 'config', value: body });
|
|
72
|
-
|
|
58
|
+
await pluginStore.set({ key: "config", value: body });
|
|
73
59
|
return this.config();
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
async restoreConfig() {
|
|
60
|
+
},
|
|
61
|
+
async restoreConfig() {
|
|
77
62
|
const pluginStore = await this.getCommonService().getPluginStore();
|
|
78
|
-
|
|
79
|
-
await pluginStore.delete({key: 'config'})
|
|
80
|
-
|
|
63
|
+
await pluginStore.delete({ key: "config" });
|
|
81
64
|
return this.config();
|
|
82
|
-
|
|
83
|
-
|
|
65
|
+
},
|
|
84
66
|
async restart() {
|
|
85
67
|
setImmediate(() => strapi.reload());
|
|
86
68
|
},
|
|
87
|
-
|
|
88
|
-
// Find all comments
|
|
89
69
|
async findAll({ related, entity, ...query }) {
|
|
90
|
-
const { _q, orderBy, pageSize = 10, page = 1, filters,
|
|
91
|
-
|
|
70
|
+
const { _q, orderBy, pageSize = 10, page = 1, filters, } = (0, functions_1.parseParams)(query);
|
|
92
71
|
const defaultWhere = {
|
|
93
|
-
$or: [
|
|
94
|
-
{ removed: false },
|
|
95
|
-
{ removed: null },
|
|
96
|
-
],
|
|
72
|
+
$or: [{ removed: false }, { removed: null }],
|
|
97
73
|
};
|
|
98
|
-
|
|
99
74
|
let params = {
|
|
100
|
-
where: !isEmpty(filters)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
75
|
+
where: !(0, lodash_1.isEmpty)(filters)
|
|
76
|
+
? {
|
|
77
|
+
...defaultWhere,
|
|
78
|
+
...filters,
|
|
79
|
+
}
|
|
80
|
+
: { ...defaultWhere },
|
|
81
|
+
offset: (page - 1) * pageSize,
|
|
105
82
|
limit: pageSize,
|
|
106
|
-
orderBy: orderBy || [{ createdAt:
|
|
83
|
+
orderBy: orderBy || [{ createdAt: "desc" }],
|
|
107
84
|
};
|
|
108
85
|
if (_q) {
|
|
109
86
|
params = {
|
|
@@ -111,34 +88,32 @@ const { APPROVAL_STATUS, REGEX } = require('./../utils/constants')
|
|
|
111
88
|
where: {
|
|
112
89
|
...params.where,
|
|
113
90
|
content: {
|
|
114
|
-
$contains: _q
|
|
91
|
+
$contains: _q,
|
|
115
92
|
},
|
|
116
|
-
}
|
|
93
|
+
},
|
|
117
94
|
};
|
|
118
95
|
}
|
|
119
|
-
|
|
120
|
-
|
|
96
|
+
const entities = await strapi.db
|
|
97
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
121
98
|
.findMany({
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
},
|
|
99
|
+
...params,
|
|
100
|
+
populate: {
|
|
101
|
+
authorUser: { populate: DEFAULT_AUTHOR_POPULATE },
|
|
102
|
+
threadOf: true,
|
|
103
|
+
reports: {
|
|
104
|
+
where: {
|
|
105
|
+
resolved: false,
|
|
130
106
|
},
|
|
131
107
|
},
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
const total = await strapi.db.query((0, functions_2.getModelUid)("comment")).count({
|
|
111
|
+
where: params.where,
|
|
112
|
+
});
|
|
137
113
|
const relatedEntities = await this.getCommonService().findRelatedEntitiesFor(entities);
|
|
138
114
|
const result = entities
|
|
139
|
-
.map(_ => filterOurResolvedReports(this.getCommonService().sanitizeCommentEntity(_)))
|
|
140
|
-
.map(_ => this.getCommonService().mergeRelatedEntityTo(_, relatedEntities));
|
|
141
|
-
|
|
115
|
+
.map((_) => (0, functions_2.filterOurResolvedReports)(this.getCommonService().sanitizeCommentEntity(_, DEFAULT_AUTHOR_POPULATE)))
|
|
116
|
+
.map((_) => this.getCommonService().mergeRelatedEntityTo(_, relatedEntities));
|
|
142
117
|
const pageCount = Math.floor(total / pageSize);
|
|
143
118
|
return {
|
|
144
119
|
result,
|
|
@@ -150,147 +125,145 @@ const { APPROVAL_STATUS, REGEX } = require('./../utils/constants')
|
|
|
150
125
|
},
|
|
151
126
|
};
|
|
152
127
|
},
|
|
153
|
-
|
|
154
|
-
// Find single comment
|
|
155
128
|
async findOneAndThread(id, { removed, ...query }) {
|
|
156
|
-
const defaultWhere = !removed
|
|
157
|
-
|
|
158
|
-
{ removed: false },
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
} : {};
|
|
162
|
-
|
|
129
|
+
const defaultWhere = !removed
|
|
130
|
+
? {
|
|
131
|
+
$or: [{ removed: false }, { removed: null }],
|
|
132
|
+
}
|
|
133
|
+
: {};
|
|
163
134
|
const reportsPopulation = {
|
|
164
135
|
reports: {
|
|
165
|
-
where: {
|
|
136
|
+
where: {
|
|
166
137
|
resolved: false,
|
|
167
138
|
},
|
|
168
|
-
}
|
|
139
|
+
},
|
|
169
140
|
};
|
|
170
|
-
|
|
171
141
|
const defaultPopulate = {
|
|
172
142
|
populate: {
|
|
173
|
-
authorUser:
|
|
143
|
+
authorUser: {
|
|
144
|
+
populate: DEFAULT_AUTHOR_POPULATE,
|
|
145
|
+
},
|
|
174
146
|
threadOf: {
|
|
175
|
-
populate: {
|
|
176
|
-
authorUser:
|
|
177
|
-
|
|
147
|
+
populate: {
|
|
148
|
+
authorUser: {
|
|
149
|
+
populate: DEFAULT_AUTHOR_POPULATE,
|
|
150
|
+
},
|
|
151
|
+
...reportsPopulation,
|
|
178
152
|
},
|
|
179
153
|
},
|
|
180
154
|
...reportsPopulation,
|
|
181
155
|
},
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
156
|
+
};
|
|
157
|
+
const entity = await strapi.db
|
|
158
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
159
|
+
.findOne({
|
|
185
160
|
where: {
|
|
186
161
|
id,
|
|
187
162
|
},
|
|
188
163
|
...defaultPopulate,
|
|
189
164
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
throw new PluginError(404, 'Not found');
|
|
165
|
+
if (!entity) {
|
|
166
|
+
throw new error_1.default(404, "Not found");
|
|
193
167
|
}
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
168
|
+
const [relatedUid, relatedStringId] = (0, functions_2.getRelatedGroups)(entity.related);
|
|
169
|
+
const parsedRelatedId = (0, lodash_1.parseInt)(relatedStringId);
|
|
170
|
+
const relatedId = (0, lodash_1.isNumber)(parsedRelatedId)
|
|
171
|
+
? parsedRelatedId
|
|
172
|
+
: relatedStringId;
|
|
173
|
+
const relatedEntity = await strapi.db
|
|
174
|
+
.query(relatedUid)
|
|
175
|
+
.findOne({
|
|
176
|
+
where: { id: relatedId },
|
|
177
|
+
})
|
|
178
|
+
.then((_) => ({
|
|
201
179
|
..._,
|
|
202
180
|
uid: relatedUid,
|
|
203
181
|
}));
|
|
204
|
-
|
|
205
182
|
if (!relatedEntity) {
|
|
206
|
-
throw new
|
|
183
|
+
throw new error_1.default(404, "Relation not found");
|
|
207
184
|
}
|
|
208
|
-
|
|
209
185
|
const levelThreadId = entity?.threadOf?.id || null;
|
|
210
|
-
const entitiesOnSameLevel = await this.getCommonService()
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}, false);
|
|
186
|
+
const entitiesOnSameLevel = await this.getCommonService().findAllInHierarchy({
|
|
187
|
+
query: {
|
|
188
|
+
...defaultWhere,
|
|
189
|
+
...query,
|
|
190
|
+
threadOf: levelThreadId,
|
|
191
|
+
related: entity.related,
|
|
192
|
+
},
|
|
193
|
+
...defaultPopulate,
|
|
194
|
+
startingFromId: levelThreadId,
|
|
195
|
+
isAdmin: true,
|
|
196
|
+
}, false);
|
|
222
197
|
const selectedEntity = this.getCommonService().sanitizeCommentEntity({
|
|
223
198
|
...entity,
|
|
224
199
|
threadOf: entity.threadOf || null,
|
|
225
|
-
});
|
|
226
|
-
|
|
200
|
+
}, DEFAULT_AUTHOR_POPULATE);
|
|
227
201
|
return {
|
|
228
202
|
entity: relatedEntity,
|
|
229
203
|
selected: selectedEntity,
|
|
230
204
|
level: entitiesOnSameLevel,
|
|
231
205
|
};
|
|
232
206
|
},
|
|
233
|
-
|
|
234
|
-
// Block / Unblock a comment
|
|
235
207
|
async blockComment(id, forceStatus) {
|
|
236
208
|
const existingEntity = await this.getCommonService().findOne({ id });
|
|
237
|
-
const changedEntity = await strapi.db
|
|
209
|
+
const changedEntity = await strapi.db
|
|
210
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
211
|
+
.update({
|
|
238
212
|
where: { id },
|
|
239
|
-
data: {
|
|
213
|
+
data: {
|
|
214
|
+
blocked: !(0, lodash_1.isNil)(forceStatus) ? forceStatus : !existingEntity.blocked,
|
|
215
|
+
},
|
|
240
216
|
});
|
|
241
217
|
return this.getCommonService().sanitizeCommentEntity(changedEntity);
|
|
242
218
|
},
|
|
243
|
-
|
|
244
|
-
// Block / Unblock a comment thread
|
|
245
219
|
async blockCommentThread(id, forceStatus) {
|
|
246
220
|
const existingEntity = await this.getCommonService().findOne({ id });
|
|
247
|
-
const status = !isNil(forceStatus)
|
|
248
|
-
|
|
221
|
+
const status = !(0, lodash_1.isNil)(forceStatus)
|
|
222
|
+
? forceStatus
|
|
223
|
+
: !existingEntity.blockedThread;
|
|
224
|
+
const changedEntity = await strapi.db
|
|
225
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
226
|
+
.update({
|
|
249
227
|
where: { id },
|
|
250
|
-
data: {
|
|
228
|
+
data: {
|
|
251
229
|
blocked: status,
|
|
252
230
|
blockedThread: status,
|
|
253
231
|
},
|
|
254
232
|
});
|
|
255
233
|
await this.blockNestedThreads(id, changedEntity.blockedThread);
|
|
256
|
-
|
|
257
234
|
return this.getCommonService().sanitizeCommentEntity(changedEntity);
|
|
258
235
|
},
|
|
259
|
-
|
|
260
|
-
// Approve comment
|
|
261
236
|
async approveComment(id) {
|
|
262
|
-
const changedEntity = await strapi.db
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
237
|
+
const changedEntity = await strapi.db
|
|
238
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
239
|
+
.update({
|
|
240
|
+
where: { id },
|
|
241
|
+
data: { approvalStatus: constants_1.APPROVAL_STATUS.APPROVED },
|
|
242
|
+
});
|
|
268
243
|
return this.getCommonService().sanitizeCommentEntity(changedEntity);
|
|
269
244
|
},
|
|
270
|
-
|
|
271
245
|
async rejectComment(id) {
|
|
272
|
-
const changedEntity = await strapi.db
|
|
273
|
-
.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
|
|
246
|
+
const changedEntity = await strapi.db
|
|
247
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
248
|
+
.update({
|
|
249
|
+
where: { id },
|
|
250
|
+
data: { approvalStatus: constants_1.APPROVAL_STATUS.REJECTED },
|
|
251
|
+
});
|
|
278
252
|
return this.getCommonService().sanitizeCommentEntity(changedEntity);
|
|
279
253
|
},
|
|
280
|
-
|
|
281
254
|
async blockNestedThreads(id, blockStatus) {
|
|
282
|
-
return await this.getCommonService()
|
|
283
|
-
.modifiedNestedNestedComments(id, 'blockedThread', blockStatus)
|
|
255
|
+
return await this.getCommonService().modifiedNestedNestedComments(id, "blockedThread", blockStatus);
|
|
284
256
|
},
|
|
285
|
-
|
|
286
|
-
// Resolve reported abuse for comment
|
|
287
257
|
async resolveAbuseReport(id, commentId) {
|
|
288
|
-
return strapi.db
|
|
258
|
+
return strapi.db
|
|
259
|
+
.query((0, functions_2.getModelUid)("comment-report"))
|
|
260
|
+
.update({
|
|
289
261
|
where: {
|
|
290
262
|
id,
|
|
291
263
|
related: commentId,
|
|
292
264
|
},
|
|
293
|
-
data: { resolved: true }
|
|
265
|
+
data: { resolved: true },
|
|
294
266
|
});
|
|
295
|
-
},
|
|
267
|
+
},
|
|
296
268
|
});
|
|
269
|
+
//# sourceMappingURL=admin.js.map
|