strapi-plugin-comments 2.0.0-beta.1 → 2.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +16 -5
  2. package/admin/src/components/DiscussionThread/index.js +3 -1
  3. package/admin/src/components/DiscussionThreadItem/index.js +4 -4
  4. package/admin/src/components/DiscussionThreadItem/styles.js +1 -0
  5. package/admin/src/components/DiscussionThreadItemActions/index.js +30 -44
  6. package/admin/src/components/DiscussionThreadItemActions/styles.js +0 -4
  7. package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +72 -0
  8. package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.js +6 -0
  9. package/admin/src/components/DiscussionThreadItemWarnings/index.js +13 -9
  10. package/admin/src/components/Nav/index.js +5 -1
  11. package/admin/src/components/ReportsReviewModal/index.js +0 -2
  12. package/admin/src/components/ReportsReviewTable/index.js +9 -5
  13. package/admin/src/components/icons/index.js +6 -0
  14. package/admin/src/components/icons/lock.js +22 -0
  15. package/admin/src/components/icons/review.js +18 -0
  16. package/admin/src/components/icons/unlock.js +20 -0
  17. package/admin/src/index.js +6 -4
  18. package/admin/src/pages/App/index.js +42 -3
  19. package/admin/src/pages/App/reducer/actions.js +8 -0
  20. package/admin/src/pages/App/reducer/constants.js +4 -0
  21. package/admin/src/pages/App/reducer/index.js +26 -0
  22. package/admin/src/pages/App/reducer/init.js +7 -0
  23. package/admin/src/pages/App/reducer/selectors.js +35 -0
  24. package/admin/src/pages/App/utils/api.js +12 -0
  25. package/admin/src/pages/Details/components/DetailsEntity/index.js +66 -0
  26. package/admin/src/pages/Details/components/DetailsFilters/index.js +36 -0
  27. package/admin/src/pages/Details/components/DetailsFilters/styles.js +8 -0
  28. package/admin/src/pages/Details/index.js +41 -14
  29. package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +190 -0
  30. package/admin/src/pages/Discover/components/DiscoverTableRow/styles.js +8 -0
  31. package/admin/src/pages/Discover/index.js +25 -50
  32. package/admin/src/pages/Discover/utils/api.js +2 -11
  33. package/admin/src/pages/{Details/utils → utils}/api.js +15 -3
  34. package/admin/src/reducers.js +8 -0
  35. package/admin/src/translations/en.json +16 -4
  36. package/admin/src/utils/constants.js +3 -6
  37. package/admin/src/utils/getMessage.js +10 -3
  38. package/admin/src/utils/getRelatedGroups.js +1 -3
  39. package/admin/src/utils/handleAPIError.js +1 -1
  40. package/admin/src/utils/index.js +4 -2
  41. package/admin/src/utils/renderEntryTitle.js +14 -0
  42. package/admin/src/utils/resolveCommentStatus.js +30 -0
  43. package/admin/src/utils/resolveCommentStatusColor.js +22 -0
  44. package/package.json +7 -3
  45. package/server/config/index.js +6 -1
  46. package/server/controllers/admin.js +8 -24
  47. package/server/controllers/client.js +11 -2
  48. package/server/services/admin.js +75 -14
  49. package/server/services/client.js +22 -14
  50. package/server/services/common.js +41 -70
  51. package/server/services/utils/functions.js +7 -14
  52. package/server/utils/constants.js +3 -3
  53. package/admin/src/components/EntityDetails/index.js +0 -53
@@ -5,21 +5,18 @@
5
5
  */
6
6
 
7
7
  import React, { memo, useRef, useMemo } from 'react';
8
- import { useIntl } from 'react-intl';
8
+ import { connect } from 'react-redux';
9
+ import { bindActionCreators, compose } from 'redux';
10
+ import isEqual from 'react-fast-compare';
9
11
  import { useQuery } from 'react-query';
10
12
  import { useHistory } from 'react-router-dom';
11
13
  import { isEmpty } from 'lodash';
12
- import { Badge } from '@strapi/design-system/Badge';
13
- import { BaseCheckbox } from '@strapi/design-system/BaseCheckbox';
14
14
  import { Box } from '@strapi/design-system/Box';
15
- import { Flex } from '@strapi/design-system/Flex';
16
- import { IconButton } from '@strapi/design-system/IconButton';
17
15
  import { Layout, HeaderLayout, ActionLayout, ContentLayout } from '@strapi/design-system/Layout';
18
16
  import { Table, Thead, Tbody, Tr, Th, Td } from '@strapi/design-system/Table';
19
17
  import { Typography } from '@strapi/design-system/Typography';
20
18
  import { VisuallyHidden } from '@strapi/design-system/VisuallyHidden';
21
19
  import { useNotifyAT } from '@strapi/design-system/LiveRegions';
22
- import { Eye } from '@strapi/icons';
23
20
 
24
21
  import {
25
22
  EmptyStateLayout,
@@ -37,12 +34,13 @@ import pluginPermissions from '../../permissions';
37
34
 
38
35
  import getUrl from '../../utils/getUrl';
39
36
  import Nav from '../../components/Nav';
40
- import { COMMENT_STATUS } from '../../utils/constants';
41
37
  import TablePagination from '../../components/TablePagination';
42
38
  import filtersSchema from './utils/filtersSchema';
43
39
  import TableFilters from '../../components/TableFilters';
40
+ import makeAppView from '../App/reducer/selectors';
41
+ import DiscoverTableRow from './components/DiscoverTableRow';
44
42
 
45
- const Discover = () => {
43
+ const Discover = ({ config }) => {
46
44
  useFocusWhenNavigate();
47
45
 
48
46
  const { push } = useHistory();
@@ -50,7 +48,6 @@ const Discover = () => {
50
48
  const { trackUsage } = useTracking();
51
49
  const trackUsageRef = useRef(trackUsage);
52
50
  const toggleNotification = useNotification();
53
- const { formatDate } = useIntl();
54
51
  const [{ query: queryParams }] = useQueryParams();
55
52
  const _q = queryParams?._q || '';
56
53
 
@@ -64,7 +61,7 @@ const Discover = () => {
64
61
  } = useRBAC(viewPermissions);
65
62
 
66
63
  const { isLoading: isLoadingForData, data: { result, pagination = {} }, isFetching } = useQuery(
67
- ['get-providers', queryParams],
64
+ ['get-data', queryParams],
68
65
  () => fetchData(queryParams, toggleNotification),
69
66
  {
70
67
  initialData: { },
@@ -89,25 +86,14 @@ const Discover = () => {
89
86
  },
90
87
  };
91
88
 
92
- const renderStatus = ({ blocked, blockedThread }) => {
93
- const status = blocked || blockedThread ? COMMENT_STATUS.BLOCKED : COMMENT_STATUS.OPEN;
94
- let color = 'secondary';
95
- switch (status) {
96
- case COMMENT_STATUS.OPEN:
97
- color = 'success';
98
- break;
99
- case COMMENT_STATUS.BLOCKED:
100
- color = 'danger';
101
- };
102
- return (<Badge backgroundColor={`${color}100`} textColor={`${color}600`}>{ getMessage(`page.discover.table.header.status.${status}`, status) }</Badge>);
103
- };
89
+
104
90
 
105
91
  const emptyContent = _q ? 'search' : 'comments';
106
92
 
107
93
  const COL_COUNT = 7;
108
94
 
109
95
  return <Box background="neutral100">
110
- <Layout sideNav={<Nav />}>
96
+ <Layout>
111
97
  {isLoading || isLoadingForPermissions ? (<LoadingIndicatorPage />) : (
112
98
  <>
113
99
  <HeaderLayout title={ getMessage('page.discover.header') } subtitle={ `${total} ${ getMessage('page.discover.header.count')}` } as="h2" />
@@ -124,7 +110,7 @@ const Discover = () => {
124
110
  <Thead>
125
111
  <Tr>
126
112
  <Th>
127
- <BaseCheckbox aria-label="Select all entries" />
113
+ <Typography variant="sigma">{ getMessage('page.discover.table.header.id') }</Typography>
128
114
  </Th>
129
115
  <Th>
130
116
  <Typography variant="sigma">{ getMessage('page.discover.table.header.message') }</Typography>
@@ -147,31 +133,7 @@ const Discover = () => {
147
133
  </Tr>
148
134
  </Thead>
149
135
  <Tbody>
150
- {result.map(entry => <Tr key={entry.id}>
151
- <Td>
152
- <BaseCheckbox aria-label={`Select ${entry.content}`} />
153
- </Td>
154
- <Td style={{ maxWidth: '40vw' }}>
155
- <Typography textColor="neutral800" ellipsis>{entry.content}</Typography>
156
- </Td>
157
- <Td>
158
- <Typography textColor="neutral800">{entry.threadOf?.id || '-'}</Typography>
159
- </Td>
160
- <Td>
161
- <Typography textColor="neutral800">{entry.related?.id}</Typography>
162
- </Td>
163
- <Td>
164
- <Typography textColor="neutral800">{ formatDate(entry.updatedAt || entry.createdAt, { dateStyle: 'long', timeStyle: 'short' }) }</Typography>
165
- </Td>
166
- <Td>
167
- <Typography textColor="neutral800">{ renderStatus(entry) }</Typography>
168
- </Td>
169
- <Td>
170
- <Flex direction="column" alignItems="flex-end">
171
- <IconButton onClick={() => handleClickDisplay(entry.id)} label={ getMessage('page.discover.table.action.display') } icon={<Eye />} />
172
- </Flex>
173
- </Td>
174
- </Tr>)}
136
+ {result.map(entry => (<DiscoverTableRow key={`comment-${entry.id}`} config={config} item={entry} onClick={() => handleClickDisplay(entry.id)}/>))}
175
137
  </Tbody>
176
138
  </Table>
177
139
  <TablePagination pagination={{ pageCount: pagination?.pageCount || 1 }} />
@@ -182,4 +144,17 @@ const Discover = () => {
182
144
  </Box>;
183
145
  }
184
146
 
185
- export default memo(Discover);
147
+ const mapStateToProps = makeAppView();
148
+
149
+ export function mapDispatchToProps(dispatch) {
150
+ return bindActionCreators(
151
+ { },
152
+ dispatch
153
+ );
154
+ }
155
+ const withConnect = connect(
156
+ mapStateToProps,
157
+ mapDispatchToProps
158
+ );
159
+
160
+ export default compose(withConnect)(memo(Discover, isEqual));
@@ -1,23 +1,14 @@
1
1
  import { stringify } from 'qs';
2
- import { isEmpty } from 'lodash';
3
2
 
4
- import { getApiURL, axiosInstance } from '../../../utils';
3
+ import { getApiURL, axiosInstance, handleAPIError } from '../../../utils';
5
4
 
6
5
  // eslint-disable-next-line import/prefer-default-export
7
6
  export const fetchData = async (queryParams, toggleNotification) => {
8
7
  try {
9
- console.log('api');
10
- console.log(queryParams);
11
- console.log(getApiURL(`moderate/all${!isEmpty(queryParams) ? `?${stringify(queryParams, { encode: false })}` : ''}`));
12
8
  const { data } = await axiosInstance.get(getApiURL(`moderate/all${queryParams ? `?${stringify(queryParams, { encode: false })}` : ''}`));
13
9
 
14
10
  return data;
15
11
  } catch (err) {
16
- toggleNotification({
17
- type: 'warning',
18
- message: { id: 'notification.error' },
19
- });
20
-
21
- throw new Error('error');
12
+ handleAPIError(err, toggleNotification);
22
13
  }
23
14
  };
@@ -1,9 +1,13 @@
1
- import { getApiURL, axiosInstance, handleAPIError } from '../../../utils';
1
+ import { stringify } from 'qs';
2
+ import { isEmpty } from 'lodash';
3
+
4
+ import { getApiURL, axiosInstance, handleAPIError } from '../../utils';
2
5
 
3
6
  // eslint-disable-next-line import/prefer-default-export
4
- export const fetchDetailsData = async (id, toggleNotification) => {
7
+ export const fetchDetailsData = async (id, queryParams, toggleNotification) => {
5
8
  try {
6
- const { data } = await axiosInstance.get(getApiURL(`moderate/single/${id}`));
9
+ const stringifiedProps = !isEmpty(queryParams) ? `?${stringify(queryParams, { encode: false })}` : '';
10
+ const { data } = await axiosInstance.get(getApiURL(`moderate/single/${id}${stringifiedProps}`));
7
11
 
8
12
  return data;
9
13
  } catch (err) {
@@ -28,6 +32,14 @@ export const unblockItem = id => {
28
32
  return axiosInstance.patch(getApiURL(`moderate/single/${id}/unblock`));
29
33
  };
30
34
 
35
+ export const approveItem = id => {
36
+ return axiosInstance.patch(getApiURL(`moderate/single/${id}/approve`));
37
+ };
38
+
39
+ export const rejectItem = id => {
40
+ return axiosInstance.patch(getApiURL(`moderate/single/${id}/reject`));
41
+ };
42
+
31
43
  export const blockItemThread = id => {
32
44
  return axiosInstance.patch(getApiURL(`moderate/thread/${id}/block`));
33
45
  };
@@ -0,0 +1,8 @@
1
+ import appReducer from './pages/App/reducer';
2
+ import { REDUCER_NAME } from './pages/App/reducer/constants';
3
+
4
+ const reducers = {
5
+ [`${REDUCER_NAME}`]: appReducer,
6
+ };
7
+
8
+ export default reducers;
@@ -7,23 +7,29 @@
7
7
  "nav.item.discover": "Discover",
8
8
  "nav.item.reports": "Reports",
9
9
  "nav.item.settings": "Settings",
10
+ "page.common.item.status.OPEN": "OPEN",
11
+ "page.common.item.status.BLOCKED": "BLOCKED",
12
+ "page.common.item.status.APPROVED": "APPROVED",
13
+ "page.common.item.status.TO_REVIEW": "TO REVIEW ({count, number})",
14
+ "page.common.item.status.REJECTED": "REJECTED",
15
+ "page.common.item.status.REMOVED": "REMOVED BY AUTHOR",
10
16
  "page.updates.header": "Recent updates",
11
17
  "page.discover.header": "Discover threads",
12
18
  "page.discover.header.count": "entries found",
19
+ "page.discover.table.header.id": "ID",
13
20
  "page.discover.table.header.message": "Message",
14
21
  "page.discover.table.header.thread": "Thread of",
15
22
  "page.discover.table.header.entry": "Entry",
16
23
  "page.discover.table.header.lastUpdate": "Last update",
17
24
  "page.discover.table.header.status": "Status",
18
- "page.discover.table.header.status.OPEN": "OPEN",
19
- "page.discover.table.header.status.BLOCKED": "BLOCKED",
20
- "page.discover.table.header.status.TO_REVIEW": "TO REVIEW",
21
- "page.discover.table.header.actions": "Status",
25
+ "page.discover.table.header.actions": "Actions",
26
+ "page.discover.table.cell.thread": "Comment #{id}",
22
27
  "page.discover.table.action.display": "Display",
23
28
  "page.discover.table.action.reports": "Reports",
24
29
  "page.discover.table.empty": "You don't have any comments yet.",
25
30
  "page.discover.table.empty.search": "No comments match the search.",
26
31
  "page.discover.table.filters": "Filtering",
32
+ "page.discover.table.reports.review": "Review reports",
27
33
  "page.details.header": "Discussion panel",
28
34
  "page.details.header.description": "Drilldown and manage discussion related to the entity",
29
35
  "page.details.panel.discussion": "Discussion",
@@ -51,6 +57,7 @@
51
57
  "page.details.panel.status.open": "OPEN",
52
58
  "page.details.panel.status.blocked": "BLOCKED",
53
59
  "page.details.panel.status.pending": "PENDING",
60
+ "page.details.panel.loading": "Fetching entity...",
54
61
  "page.details.actions.comment.block": "Block comment",
55
62
  "page.details.actions.comment.block.confirmation.header": "Moderation: Block comment",
56
63
  "page.details.actions.comment.block.confirmation.description": "Do you really want to block this comment?",
@@ -66,6 +73,11 @@
66
73
  "page.details.actions.thread.block.confirmation.success": "Thread has been blocked",
67
74
  "page.details.actions.thread.unblock": "Unblock thread",
68
75
  "page.details.actions.thread.unblock.confirmation.success": "Thread has been unblocked",
76
+ "page.details.actions.comment.approve.confirmation.success": "Comment has been approved",
77
+ "page.details.actions.comment.reject.confirmation.success": "Comment has been rejected",
78
+ "page.details.filters.label": "View",
79
+ "page.details.filters.removed.show": "Show removed",
80
+ "page.details.filters.removed.hide": "Hide removed",
69
81
  "page.coming.soon": "Wait for what is coming soon...",
70
82
  "compontents.confirmation.dialog.header": "Confirmation",
71
83
  "compontents.confirmation.dialog.description": "Do you really want to perform this action?",
@@ -16,13 +16,10 @@ export const REPORT_REASON = {
16
16
  };
17
17
 
18
18
  export const COMMENT_STATUS = {
19
+ 'UNKNOWN': 'UNKNOWN',
19
20
  'BLOCKED': 'BLOCKED',
20
21
  'OPEN': 'OPEN',
22
+ 'REMOVED': 'REMOVED',
21
23
  'TO_REVIEW': 'TO_REVIEW',
22
- };
23
-
24
- export const REGEX = {
25
- uid: new RegExp(/^(?<type>[a-z]+)\:{2}(?<api>[a-z]+)\.{1}(?<contentType>[a-z]+)$/gmi),
26
- relatedUid: new RegExp(/^(?<uid>[a-z]+\:{2}[a-z]+\.[a-z]+)\:{1}(?<id>[0-9]+)$/gmi),
27
- email: new RegExp(/\S+@\S+\.\S+/),
24
+ ...APPROVAL_STATUS,
28
25
  };
@@ -1,14 +1,21 @@
1
1
 
2
2
  import { useIntl } from 'react-intl';
3
+ import { isString } from 'lodash';
3
4
 
4
5
  import pluginId from '../pluginId';
5
6
 
6
- const getMessage = (id, defaultMessage, inPluginScope = true) => {
7
+ const getMessage = (input, defaultMessage = '', inPluginScope = true) => {
7
8
  const { formatMessage } = useIntl();
9
+ let formattedId = ''
10
+ if (isString(input)) {
11
+ formattedId = input;
12
+ } else {
13
+ formattedId = input?.id;
14
+ }
8
15
  return formatMessage({
9
- id: `${inPluginScope ? pluginId : 'app.component'}.${id}`,
16
+ id: `${inPluginScope ? pluginId : 'app.components'}.${formattedId}`,
10
17
  defaultMessage,
11
- })
18
+ }, input?.props || undefined)
12
19
  };
13
20
 
14
21
  export default getMessage;
@@ -1,5 +1,3 @@
1
- import { REGEX } from "./constants";
2
-
3
- const getRelatedGroups = related => related.split(REGEX.relatedUid).filter(s => s && s.length > 0);
1
+ const getRelatedGroups = (related, config) => related.split(config.regex.relatedUid).filter(s => s && s.length > 0);
4
2
 
5
3
  export default getRelatedGroups;
@@ -2,7 +2,7 @@
2
2
  const handleAPIError = (err = null, toggleNotification = null) => {
3
3
  toggleNotification({
4
4
  type: 'warning',
5
- message: { id: 'notification.error' },
5
+ message: 'app.components.notification.error',
6
6
  });
7
7
 
8
8
  if (err) {
@@ -1,6 +1,8 @@
1
1
  export { default as axiosInstance } from './axiosInstance';
2
- export { default as getApiURL } from './getApiURL';
2
+ export { default as getApiURL } from './getApiUrl';
3
3
  export { default as getUrl } from './getUrl';
4
4
  export { default as getMessage } from './getMessage';
5
5
  export { default as handleAPIError } from './handleAPIError';
6
- export { default as getRelatedGroups } from './getRelatedGroups';
6
+ export { default as getRelatedGroups } from './getRelatedGroups';
7
+ export { default as resolveCommentStatus } from './resolveCommentStatus';
8
+ export { default as resolveCommentStatusColor } from './resolveCommentStatusColor';
@@ -0,0 +1,14 @@
1
+ import { first } from 'lodash';
2
+
3
+ const renderEntryTitle = (entry, config = {}) => {
4
+ const { entryLabel } = config;
5
+ const rule = entry.uid in entryLabel ? entryLabel[entry.uid] : entryLabel['*'];
6
+ return first(
7
+ Object.keys(entry)
8
+ .filter(_ => (rule === _) || rule.includes(_))
9
+ .map(_ => entry[_])
10
+ .filter(_ => _)
11
+ );
12
+ };
13
+
14
+ export default renderEntryTitle;
@@ -0,0 +1,30 @@
1
+ import { isNil } from 'lodash';
2
+ import { COMMENT_STATUS } from './constants';
3
+
4
+ const resolveCommentStatus = ({ removed, blocked, blockedThread, approvalStatus, reviewFlowEnabled }) => {
5
+ const gotApprovalFlow = !isNil(approvalStatus);
6
+
7
+ if (reviewFlowEnabled) {
8
+ return COMMENT_STATUS.TO_REVIEW;
9
+ }
10
+
11
+ if (removed) {
12
+ return COMMENT_STATUS.REMOVED;
13
+ }
14
+
15
+ if (blocked || blockedThread) {
16
+ return COMMENT_STATUS.BLOCKED;
17
+ }
18
+
19
+ if (gotApprovalFlow) {
20
+ const status = approvalStatus.toUpperCase();
21
+ if (Object.keys(COMMENT_STATUS).includes(status)) {
22
+ return status;
23
+ }
24
+ return COMMENT_STATUS.UNKNOWN;
25
+ }
26
+
27
+ return COMMENT_STATUS.OPEN;
28
+ }
29
+
30
+ export default resolveCommentStatus;
@@ -0,0 +1,22 @@
1
+ import { isNil } from 'lodash';
2
+ import { COMMENT_STATUS } from './constants';
3
+
4
+ const resolveCommentStatusColor = (status) => {
5
+ if (Object.keys(COMMENT_STATUS).includes(status)) {
6
+ switch (status) {
7
+ case COMMENT_STATUS.REMOVED:
8
+ return 'secondary';
9
+ case COMMENT_STATUS.TO_REVIEW:
10
+ case COMMENT_STATUS.REJECTED:
11
+ return 'warning';
12
+ case COMMENT_STATUS.BLOCKED:
13
+ return 'danger';
14
+ case COMMENT_STATUS.OPEN:
15
+ case COMMENT_STATUS.APPROVED:
16
+ return 'success';
17
+ };
18
+ }
19
+ return 'secondary';
20
+ }
21
+
22
+ export default resolveCommentStatusColor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-comments",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.5",
4
4
  "description": "Strapi - Comments plugin",
5
5
  "strapi": {
6
6
  "name": "comments",
@@ -15,6 +15,7 @@
15
15
  "url": "https://github.com/VirtusLab-Open-Source/strapi-plugin-comments"
16
16
  },
17
17
  "dependencies": {
18
+ "@strapi/utils": "^4.0.5",
18
19
  "bad-words": "^3.0.4"
19
20
  },
20
21
  "devDependencies": {
@@ -23,6 +24,9 @@
23
24
  "jest-cli": "^26.0.1",
24
25
  "jest-styled-components": "^7.0.2"
25
26
  },
27
+ "peerDependencies": {
28
+ "@strapi/strapi": "4.x"
29
+ },
26
30
  "author": {
27
31
  "name": "VirtusLab // Mateusz Ziarko",
28
32
  "email": "mziarko@virtuslab.com",
@@ -41,8 +45,8 @@
41
45
  }
42
46
  ],
43
47
  "engines": {
44
- "node": ">=12.x. <=16.x.x",
45
- "npm": ">=6.0.0"
48
+ "node": ">=14.x.x <=17.x.x",
49
+ "npm": ">=7.x.x"
46
50
  },
47
51
  "keywords": ["strapi", "plugin", "comments"],
48
52
  "license": "MIT"
@@ -1,6 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports = {
4
- default: {},
4
+ default: {
5
+ approvalFlow: [],
6
+ entryLabel: {
7
+ '*': ['Title', 'title', 'Name', 'name', 'Subject', 'subject']
8
+ },
9
+ },
5
10
  validator() {},
6
11
  };
@@ -16,11 +16,11 @@ module.exports = {
16
16
  },
17
17
 
18
18
  async findOne(ctx) {
19
- const { params = {} } = ctx;
19
+ const { params = {}, query } = ctx;
20
20
  const { id } = parseParams(params);
21
21
  try {
22
22
  return await this.getService()
23
- .findOneAndThread(id);
23
+ .findOneAndThread(id, query);
24
24
  } catch (e) {
25
25
  throwError(ctx, e);
26
26
  }
@@ -101,28 +101,12 @@ module.exports = {
101
101
  }
102
102
  },
103
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
- };
104
+ async config(ctx) {
105
+ try {
106
+ return await this.getService().config();
107
+ } catch (e) {
108
+ throwError(ctx, e);
109
+ }
126
110
  },
127
111
 
128
112
  getContentsTypes() {
@@ -16,8 +16,14 @@ module.exports = {
16
16
  try {
17
17
  return this.getService('common')
18
18
  .findAllFlat({
19
- ...query,
20
- related: relation,
19
+ query: {
20
+ ...query,
21
+ $or: [{ removed: { $null: true } }, { removed: false }],
22
+ related: relation,
23
+ },
24
+ populate: {
25
+ threadOf: true,
26
+ },
21
27
  });
22
28
  } catch (e) {
23
29
  throwError(ctx, e);
@@ -34,6 +40,9 @@ module.exports = {
34
40
  ...query,
35
41
  related: relation,
36
42
  },
43
+ populate: {
44
+ threadOf: true,
45
+ },
37
46
  dropBlockedThreads: true,
38
47
  });
39
48
  } catch (e) {