strapi-plugin-comments 2.3.1 → 3.0.0-beta.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/LICENSE.md +7 -0
- package/README.md +21 -19
- package/dist/_chunks/en-D1Rj1A_i.js +195 -0
- package/{admin/src/translations/en.json → dist/_chunks/en-DZljqkLz.mjs} +17 -14
- package/dist/_chunks/fr-DbxNAr65.js +146 -0
- package/{admin/src/translations/fr.json → dist/_chunks/fr-oAh2cU0E.mjs} +15 -11
- package/dist/_chunks/index-B6Q4U8YQ.js +51665 -0
- package/dist/_chunks/index-BQERo8pN.mjs +8340 -0
- package/dist/_chunks/index-BVj8EXjI.js +8356 -0
- package/dist/_chunks/index-Bpbf7RON.mjs +51643 -0
- package/dist/_chunks/index-CTjupB9v.js +375 -0
- package/dist/_chunks/index-fAgatqD0.js +50888 -0
- package/dist/_chunks/index-fSb-gYwg.mjs +373 -0
- package/dist/_chunks/index-h-TB6Qu2.mjs +50873 -0
- package/{admin/src/translations/pl.json → dist/_chunks/pl-BUVUFx9r.mjs} +14 -11
- package/dist/_chunks/pl-CuTgrHph.js +195 -0
- package/dist/_chunks/pt-BR-2Z9CtgSm.js +145 -0
- package/{admin/src/translations/pt-BR.json → dist/_chunks/pt-BR-Bchhsf7B.mjs} +14 -11
- package/{admin/src/translations/ru.json → dist/_chunks/ru-BQ54P0xr.mjs} +17 -14
- package/dist/_chunks/ru-gtnRlbuP.js +195 -0
- package/{admin/src/translations/tr.json → dist/_chunks/tr-CkGcBRUv.mjs} +14 -11
- package/dist/_chunks/tr-Ucl3IKMX.js +193 -0
- package/{admin/src/translations/zh-Hans.json → dist/_chunks/zh-Hans-Buh0iPWA.mjs} +17 -14
- package/dist/_chunks/zh-Hans-Dhk3gIYb.js +195 -0
- package/dist/admin/index.js +4 -0
- package/dist/admin/index.mjs +5 -0
- package/dist/admin/src/api/client.d.ts +413 -0
- package/dist/admin/src/api/index.d.ts +1 -0
- package/dist/admin/src/api/schemas.d.ts +3463 -0
- package/dist/admin/src/components/ActionButton/index.d.ts +4 -0
- package/dist/admin/src/components/ApproveFlow/index.d.ts +7 -0
- package/dist/admin/src/components/CommentReportStatusBadge/index.d.ts +4 -0
- package/dist/admin/src/components/CommentRow/index.d.ts +7 -0
- package/dist/admin/src/components/CommentStatusBadge/index.d.ts +7 -0
- package/dist/admin/src/components/ConfirmationDialog/index.d.ts +14 -0
- package/dist/admin/src/components/DiscussionThreadItem/DiscussionThreadItemActions.d.ts +3 -0
- package/dist/admin/src/components/DiscussionThreadItem/DiscussionThreadItemFooter.d.ts +4 -0
- package/dist/admin/src/components/DiscussionThreadItem/index.d.ts +6 -0
- package/dist/admin/src/components/DiscussionThreadItem/props.d.ts +12 -0
- package/dist/admin/src/components/IconButtonGroup/index.d.ts +5 -0
- package/dist/admin/src/components/LoadingIndicatorOverlay/index.d.ts +1 -0
- package/dist/admin/src/components/ModeratorResponseModal/index.d.ts +9 -0
- package/dist/admin/src/components/PluginIcon/index.d.ts +7 -0
- package/dist/admin/src/components/RenderIf/index.d.ts +7 -0
- package/dist/admin/src/components/ReportReasonBadge/index.d.ts +3 -0
- package/dist/admin/src/components/ReportStatusBadge/index.d.ts +5 -0
- package/dist/admin/src/components/ReportsTableRow/BlockMenu.d.ts +8 -0
- package/dist/admin/src/components/ReportsTableRow/CommentReviewModal.d.ts +7 -0
- package/dist/admin/src/components/ReportsTableRow/ReportsActions.d.ts +7 -0
- package/dist/admin/src/components/ReportsTableRow/index.d.ts +9 -0
- package/dist/admin/src/components/ReviewFlow/ReportReviewTable.d.ts +13 -0
- package/dist/admin/src/components/ReviewFlow/index.d.ts +7 -0
- package/dist/admin/src/components/SideNav/index.d.ts +1 -0
- package/dist/admin/src/components/StatusBadge/index.d.ts +3 -0
- package/dist/admin/src/components/UserAvatar/AdminAvatar.d.ts +2 -0
- package/dist/admin/src/components/UserAvatar/index.d.ts +8 -0
- package/{admin → dist/admin}/src/components/Wysiwyg/Editor.d.ts +2 -14
- package/dist/admin/src/components/Wysiwyg/EditorLayout.d.ts +12 -0
- package/{admin → dist/admin}/src/components/Wysiwyg/PreviewWysiwyg.d.ts +1 -2
- package/dist/admin/src/components/Wysiwyg/WysiwygFooter.d.ts +6 -0
- package/{admin → dist/admin}/src/components/Wysiwyg/WysiwygNav.d.ts +4 -3
- package/dist/admin/src/components/Wysiwyg/WysiwygStyles.d.ts +5 -0
- package/dist/admin/src/components/Wysiwyg/index.d.ts +13 -0
- package/{admin → dist/admin}/src/components/Wysiwyg/utils/continueList.d.ts +1 -4
- package/{admin → dist/admin}/src/components/Wysiwyg/utils/mdRenderer.d.ts +0 -1
- package/dist/admin/src/components/Wysiwyg/utils/urls.d.ts +2 -0
- package/{admin → dist/admin}/src/components/Wysiwyg/utils/utils.d.ts +0 -1
- package/{admin → dist/admin}/src/components/icons/comments.d.ts +1 -2
- package/dist/admin/src/components/icons/index.d.ts +2 -0
- package/dist/admin/src/components/icons/lock.d.ts +8 -0
- package/dist/admin/src/components/icons/review.d.ts +7 -0
- package/dist/admin/src/components/icons/strapiIcons.d.ts +1 -0
- package/dist/admin/src/components/icons/unlock.d.ts +8 -0
- package/dist/admin/src/contexts/UserContext.d.ts +23 -0
- package/dist/admin/src/hooks/useAPI.d.ts +430 -0
- package/dist/admin/src/hooks/useCommentMutations.d.ts +72 -0
- package/dist/admin/src/hooks/useCommentsAll.d.ts +59 -0
- package/dist/admin/src/hooks/useConfig.d.ts +28 -0
- package/dist/admin/src/hooks/useElementOnScreen.d.ts +2 -0
- package/dist/admin/src/hooks/usePermissions.d.ts +9 -0
- package/dist/admin/src/hooks/useReports.d.ts +60 -0
- package/dist/admin/src/hooks/useResizeObserver.d.ts +2 -0
- package/dist/admin/src/hooks/useUserContext.d.ts +21 -0
- package/dist/admin/src/index.d.ts +10 -0
- package/dist/admin/src/pages/App/index.d.ts +2 -0
- package/dist/admin/src/pages/Details/DetailsEntry.d.ts +11 -0
- package/dist/admin/src/pages/Details/DiscussionThread.d.ts +11 -0
- package/dist/admin/src/pages/Details/ModeratorResponse.d.ts +7 -0
- package/dist/admin/src/pages/Details/index.d.ts +5 -0
- package/dist/admin/src/pages/Discover/index.d.ts +5 -0
- package/dist/admin/src/pages/Reports/index.d.ts +5 -0
- package/dist/admin/src/pages/Settings/hooks/useSettingsAPI.d.ts +70 -0
- package/dist/admin/src/pages/Settings/index.d.ts +2 -0
- package/{admin → dist/admin}/src/permissions.d.ts +0 -1
- package/{admin → dist/admin}/src/pluginId.d.ts +0 -1
- package/dist/admin/src/providers/CommonProviders/index.d.ts +4 -0
- package/dist/admin/src/store/settings.store.d.ts +7 -0
- package/dist/admin/src/translations/en.d.ts +194 -0
- package/dist/admin/src/translations/fr.d.ts +143 -0
- package/dist/admin/src/translations/index.d.ts +11 -0
- package/dist/admin/src/translations/pl.d.ts +193 -0
- package/dist/admin/src/translations/pt-BR.d.ts +143 -0
- package/dist/admin/src/translations/ru.d.ts +193 -0
- package/dist/admin/src/translations/tr.d.ts +191 -0
- package/dist/admin/src/translations/zh-Hans.d.ts +193 -0
- package/dist/admin/src/types/index.d.ts +5 -0
- package/dist/admin/src/utils/constants.d.ts +28 -0
- package/{admin → dist/admin}/src/utils/errors.d.ts +0 -1
- package/{admin → dist/admin}/src/utils/functions.d.ts +0 -1
- package/{admin → dist/admin}/src/utils/getApiUrl.d.ts +0 -1
- package/dist/admin/src/utils/getMessage.d.ts +2 -0
- package/{admin → dist/admin}/src/utils/getRelatedGroups.d.ts +0 -1
- package/{admin → dist/admin}/src/utils/getUrl.d.ts +0 -1
- package/dist/admin/src/utils/handleAPIError.d.ts +2 -0
- package/{admin → dist/admin}/src/utils/index.d.ts +0 -2
- package/{admin → dist/admin}/src/utils/parseRegExp.d.ts +0 -1
- package/dist/admin/src/utils/renderEntryTitle.d.ts +2 -0
- package/{admin → dist/admin}/src/utils/renderInitials.d.ts +0 -1
- package/dist/admin/src/utils/resolveCommentStatus.d.ts +7 -0
- package/dist/admin/src/utils/resolveCommentStatusColor.d.ts +3 -0
- package/dist/admin/src/utils/resolveReportStatus.d.ts +4 -0
- package/dist/admin/src/utils/resolveReportStatusColor.d.ts +3 -0
- package/dist/assets/configuration.png +0 -0
- package/dist/assets/logo.png +0 -0
- package/dist/assets/marketplace.png +0 -0
- package/dist/assets/preview.png +0 -0
- package/dist/server/index.js +8121 -0
- package/dist/server/index.mjs +8122 -0
- package/dist/server/src/@types-v5/controllers.d.ts +17 -0
- package/dist/server/src/@types-v5/index.d.ts +5 -0
- package/dist/server/src/@types-v5/repositories.d.ts +28 -0
- package/dist/server/src/@types-v5/routes.d.ts +18 -0
- package/{types/contentTypes.d.ts → dist/server/src/@types-v5/utils.d.ts} +23 -6
- package/dist/server/src/bootstrap.d.ts +3 -0
- package/dist/server/src/config/index.d.ts +101 -0
- package/dist/server/src/const/REGEX.d.ts +19 -0
- package/dist/server/src/const/REPORT_REASON.d.ts +5 -0
- package/dist/server/src/const/index.d.ts +3 -0
- package/dist/server/src/content-types/comments/index.d.ts +98 -0
- package/{content-types/comment.d.ts → dist/server/src/content-types/comments/schema.d.ts} +3 -1
- package/{content-types → dist/server/src/content-types}/index.d.ts +14 -8
- package/dist/server/src/content-types/report/index.d.ts +50 -0
- package/{content-types/report.d.ts → dist/server/src/content-types/report/schema.d.ts} +4 -3
- package/dist/server/src/controllers/admin.controller.d.ts +964 -0
- package/dist/server/src/controllers/client.controller.d.ts +839 -0
- package/dist/server/src/controllers/index.d.ts +2641 -0
- package/dist/server/src/controllers/settings.controller.d.ts +123 -0
- package/dist/server/src/controllers/utils/parsers.d.ts +1 -0
- package/dist/server/src/index.d.ts +9448 -0
- package/{permissions.d.ts → dist/server/src/permissions.d.ts} +2 -4
- package/{server → dist/server/src}/register/custom-fields/comments.d.ts +0 -1
- package/dist/server/src/register/custom-fields/index.d.ts +2 -0
- package/{server → dist/server/src}/register/index.d.ts +1 -2
- package/dist/server/src/repositories/comment.repository.d.ts +13 -0
- package/dist/server/src/repositories/index.d.ts +5 -0
- package/dist/server/src/repositories/report.comment.repository.d.ts +41 -0
- package/dist/server/src/repositories/store.repository.d.ts +106 -0
- package/dist/server/src/repositories/utils.d.ts +11 -0
- package/dist/server/src/routes/admin.routes.d.ts +3 -0
- package/dist/server/src/routes/client.routes.d.ts +3 -0
- package/dist/server/src/routes/index.d.ts +11 -0
- package/dist/server/src/services/admin/admin.service.d.ts +2570 -0
- package/dist/server/src/services/admin/utils.d.ts +72 -0
- package/dist/server/src/services/client.service.d.ts +2056 -0
- package/dist/server/src/services/common.service.d.ts +523 -0
- package/dist/server/src/services/index.d.ts +6606 -0
- package/dist/server/src/services/settings.service.d.ts +93 -0
- package/dist/server/src/services/utils/functions.d.ts +12 -0
- package/dist/server/src/utils/Either.d.ts +16 -0
- package/dist/server/src/utils/PluginError.d.ts +11 -0
- package/dist/server/src/utils/constants.d.ts +25 -0
- package/{server → dist/server/src}/utils/error.d.ts +0 -1
- package/dist/server/src/utils/getConfig.d.ts +3 -0
- package/dist/server/src/utils/getPluginService.d.ts +3 -0
- package/dist/server/src/utils/throwError.d.ts +3 -0
- package/dist/server/src/utils/tryCatch.d.ts +1 -0
- package/{server → dist/server/src}/utils/types.d.ts +3 -5
- package/dist/server/src/validators/api/controllers/admin.controller.validator.d.ts +119 -0
- package/dist/server/src/validators/api/controllers/client.controller.validator.d.ts +586 -0
- package/dist/server/src/validators/api/controllers/index.d.ts +3 -0
- package/dist/server/src/validators/api/controllers/settings.controller.validator.d.ts +18 -0
- package/dist/server/src/validators/api/index.d.ts +1 -0
- package/dist/server/src/validators/repositories/comment.schema.d.ts +62 -0
- package/dist/server/src/validators/repositories/comment.validator.d.ts +2944 -0
- package/dist/server/src/validators/repositories/index.d.ts +2 -0
- package/dist/server/src/validators/repositories/reports.validator.d.ts +1045 -0
- package/dist/server/src/validators/repositories/utils.d.ts +20 -0
- package/dist/server/src/validators/utils.d.ts +776 -0
- package/dist/style.css +84 -0
- package/package.json +81 -18
- package/admin/src/components/ActionButton/styles.d.ts +0 -2
- package/admin/src/components/ActionButton/styles.js +0 -15
- package/admin/src/components/AdminAvatar/index.d.ts +0 -4
- package/admin/src/components/AdminAvatar/index.js +0 -17
- package/admin/src/components/AdminAvatar/styles.d.ts +0 -3
- package/admin/src/components/AdminAvatar/styles.js +0 -25
- package/admin/src/components/Avatar/index.d.ts +0 -10
- package/admin/src/components/Avatar/index.js +0 -22
- package/admin/src/components/CommentReviewModal/index.d.ts +0 -10
- package/admin/src/components/CommentReviewModal/index.js +0 -19
- package/admin/src/components/ConfirmationDialog/index.d.ts +0 -27
- package/admin/src/components/ConfirmationDialog/index.js +0 -37
- package/admin/src/components/DiscussionStatus/index.d.ts +0 -9
- package/admin/src/components/DiscussionStatus/index.js +0 -24
- package/admin/src/components/DiscussionThread/index.d.ts +0 -21
- package/admin/src/components/DiscussionThread/index.js +0 -45
- package/admin/src/components/DiscussionThreadItem/index.d.ts +0 -3
- package/admin/src/components/DiscussionThreadItem/index.js +0 -51
- package/admin/src/components/DiscussionThreadItem/styles.d.ts +0 -5
- package/admin/src/components/DiscussionThreadItem/styles.js +0 -31
- package/admin/src/components/DiscussionThreadItemActions/index.d.ts +0 -22
- package/admin/src/components/DiscussionThreadItemActions/index.js +0 -222
- package/admin/src/components/DiscussionThreadItemActions/styles.d.ts +0 -2
- package/admin/src/components/DiscussionThreadItemActions/styles.js +0 -13
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.d.ts +0 -19
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +0 -67
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.d.ts +0 -2
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.js +0 -12
- package/admin/src/components/DiscussionThreadItemFooter/index.d.ts +0 -23
- package/admin/src/components/DiscussionThreadItemFooter/index.js +0 -40
- package/admin/src/components/DiscussionThreadItemFooter/styles.d.ts +0 -3
- package/admin/src/components/DiscussionThreadItemFooter/styles.js +0 -18
- package/admin/src/components/DiscussionThreadItemReviewAction/index.d.ts +0 -25
- package/admin/src/components/DiscussionThreadItemReviewAction/index.js +0 -174
- package/admin/src/components/FormSwitch/index.d.ts +0 -7
- package/admin/src/components/FormSwitch/index.js +0 -15
- package/admin/src/components/FormSwitch/styles.d.ts +0 -2
- package/admin/src/components/FormSwitch/styles.js +0 -14
- package/admin/src/components/Hint/index.d.ts +0 -14
- package/admin/src/components/Hint/index.js +0 -22
- package/admin/src/components/IconButton/styles.d.ts +0 -2
- package/admin/src/components/IconButton/styles.js +0 -21
- package/admin/src/components/Initializer/index.d.ts +0 -5
- package/admin/src/components/Initializer/index.js +0 -14
- package/admin/src/components/LoadingIndicatorOverlay/index.d.ts +0 -3
- package/admin/src/components/LoadingIndicatorOverlay/index.js +0 -12
- package/admin/src/components/LoadingIndicatorOverlay/styles.d.ts +0 -3
- package/admin/src/components/LoadingIndicatorOverlay/styles.js +0 -25
- package/admin/src/components/ModeratorResponse/index.d.ts +0 -8
- package/admin/src/components/ModeratorResponse/index.js +0 -106
- package/admin/src/components/ModeratorResponse/styles.d.ts +0 -2
- package/admin/src/components/ModeratorResponse/styles.js +0 -12
- package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.d.ts +0 -11
- package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.js +0 -95
- package/admin/src/components/Nav/index.d.ts +0 -7
- package/admin/src/components/Nav/index.js +0 -23
- package/admin/src/components/PluginIcon/index.d.ts +0 -3
- package/admin/src/components/PluginIcon/index.js +0 -6
- package/admin/src/components/PreviewWysiwyg/Wrapper.d.ts +0 -3
- package/admin/src/components/PreviewWysiwyg/Wrapper.js +0 -162
- package/admin/src/components/PreviewWysiwyg/index.d.ts +0 -7
- package/admin/src/components/PreviewWysiwyg/index.js +0 -39
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.d.ts +0 -3
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.js +0 -88
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.d.ts +0 -20
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +0 -18
- package/admin/src/components/ReportsActions/components/BlockMenu/index.d.ts +0 -15
- package/admin/src/components/ReportsActions/components/BlockMenu/index.js +0 -51
- package/admin/src/components/ReportsActions/index.d.ts +0 -11
- package/admin/src/components/ReportsActions/index.js +0 -31
- package/admin/src/components/ReportsReviewModal/index.d.ts +0 -26
- package/admin/src/components/ReportsReviewModal/index.js +0 -33
- package/admin/src/components/ReportsReviewTable/index.d.ts +0 -15
- package/admin/src/components/ReportsReviewTable/index.js +0 -141
- package/admin/src/components/StatusBadge/index.d.ts +0 -7
- package/admin/src/components/StatusBadge/index.js +0 -12
- package/admin/src/components/StatusBadge/styles.d.ts +0 -2
- package/admin/src/components/StatusBadge/styles.js +0 -23
- package/admin/src/components/TableFilters/index.d.ts +0 -19
- package/admin/src/components/TableFilters/index.js +0 -56
- package/admin/src/components/TablePagination/index.d.ts +0 -23
- package/admin/src/components/TablePagination/index.js +0 -33
- package/admin/src/components/Wysiwyg/Editor.js +0 -439
- package/admin/src/components/Wysiwyg/EditorLayout.d.ts +0 -13
- package/admin/src/components/Wysiwyg/EditorLayout.js +0 -85
- package/admin/src/components/Wysiwyg/Field.d.ts +0 -15
- package/admin/src/components/Wysiwyg/Field.js +0 -135
- package/admin/src/components/Wysiwyg/PreviewWysiwyg.js +0 -191
- package/admin/src/components/Wysiwyg/WysiwygFooter.d.ts +0 -8
- package/admin/src/components/Wysiwyg/WysiwygFooter.js +0 -44
- package/admin/src/components/Wysiwyg/WysiwygNav.js +0 -114
- package/admin/src/components/Wysiwyg/WysiwygStyles.d.ts +0 -7
- package/admin/src/components/Wysiwyg/WysiwygStyles.js +0 -54
- package/admin/src/components/Wysiwyg/utils/continueList.js +0 -83
- package/admin/src/components/Wysiwyg/utils/mdRenderer.js +0 -63
- package/admin/src/components/Wysiwyg/utils/utils.js +0 -250
- package/admin/src/components/icons/comments.js +0 -12
- package/admin/src/components/icons/index.d.ts +0 -3
- package/admin/src/components/icons/index.js +0 -29
- package/admin/src/components/icons/lock.d.ts +0 -7
- package/admin/src/components/icons/lock.js +0 -12
- package/admin/src/components/icons/review.d.ts +0 -7
- package/admin/src/components/icons/review.js +0 -12
- package/admin/src/components/icons/strapiIcons.d.ts +0 -26
- package/admin/src/components/icons/strapiIcons.js +0 -38
- package/admin/src/components/icons/unlock.d.ts +0 -7
- package/admin/src/components/icons/unlock.js +0 -12
- package/admin/src/custom-fields/comments/components/icon.d.ts +0 -2
- package/admin/src/custom-fields/comments/components/icon.js +0 -14
- package/admin/src/custom-fields/comments/components/index.d.ts +0 -3
- package/admin/src/custom-fields/comments/components/index.js +0 -19
- package/admin/src/custom-fields/comments/components/input/consts.d.ts +0 -3
- package/admin/src/custom-fields/comments/components/input/consts.js +0 -9
- package/admin/src/custom-fields/comments/components/input/index.d.ts +0 -3
- package/admin/src/custom-fields/comments/components/input/index.js +0 -5
- package/admin/src/custom-fields/comments/components/input/input.d.ts +0 -4
- package/admin/src/custom-fields/comments/components/input/input.js +0 -98
- package/admin/src/custom-fields/comments/components/input/types.d.ts +0 -10
- package/admin/src/custom-fields/comments/components/input/types.js +0 -3
- package/admin/src/custom-fields/comments/components/input/utils.d.ts +0 -26
- package/admin/src/custom-fields/comments/components/input/utils.js +0 -141
- package/admin/src/custom-fields/comments/index.d.ts +0 -3
- package/admin/src/custom-fields/comments/index.js +0 -53
- package/admin/src/custom-fields/index.d.ts +0 -3
- package/admin/src/custom-fields/index.js +0 -13
- package/admin/src/hooks/useConfig.d.ts +0 -8
- package/admin/src/hooks/useConfig.js +0 -41
- package/admin/src/hooks/useReportsActionsHandlers.d.ts +0 -19
- package/admin/src/hooks/useReportsActionsHandlers.js +0 -70
- package/admin/src/index.d.ts +0 -15
- package/admin/src/index.js +0 -97
- package/admin/src/pages/App/index.d.ts +0 -15
- package/admin/src/pages/App/index.js +0 -47
- package/admin/src/pages/App/reducer/actions.d.ts +0 -8
- package/admin/src/pages/App/reducer/actions.js +0 -12
- package/admin/src/pages/App/reducer/constants.d.ts +0 -4
- package/admin/src/pages/App/reducer/constants.js +0 -7
- package/admin/src/pages/App/reducer/index.d.ts +0 -9
- package/admin/src/pages/App/reducer/index.js +0 -28
- package/admin/src/pages/App/reducer/init.d.ts +0 -3
- package/admin/src/pages/App/reducer/init.js +0 -9
- package/admin/src/pages/App/reducer/selectors.d.ts +0 -10
- package/admin/src/pages/App/reducer/selectors.js +0 -18
- package/admin/src/pages/App/utils/api.d.ts +0 -2
- package/admin/src/pages/App/utils/api.js +0 -15
- package/admin/src/pages/ComingSoonPage/index.d.ts +0 -4
- package/admin/src/pages/ComingSoonPage/index.js +0 -43
- package/admin/src/pages/Details/components/DetailsEntity/index.d.ts +0 -19
- package/admin/src/pages/Details/components/DetailsEntity/index.js +0 -56
- package/admin/src/pages/Details/components/DetailsFilters/index.d.ts +0 -13
- package/admin/src/pages/Details/components/DetailsFilters/index.js +0 -28
- package/admin/src/pages/Details/components/DetailsFilters/styles.d.ts +0 -2
- package/admin/src/pages/Details/components/DetailsFilters/styles.js +0 -14
- package/admin/src/pages/Details/index.d.ts +0 -11
- package/admin/src/pages/Details/index.js +0 -100
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.d.ts +0 -25
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +0 -125
- package/admin/src/pages/Discover/components/DiscoverTableRow/styles.d.ts +0 -2
- package/admin/src/pages/Discover/components/DiscoverTableRow/styles.js +0 -14
- package/admin/src/pages/Discover/index.d.ts +0 -11
- package/admin/src/pages/Discover/index.js +0 -132
- package/admin/src/pages/Discover/utils/api.d.ts +0 -2
- package/admin/src/pages/Discover/utils/api.js +0 -16
- package/admin/src/pages/Discover/utils/filtersSchema.d.ts +0 -26
- package/admin/src/pages/Discover/utils/filtersSchema.js +0 -39
- package/admin/src/pages/NoAccessPage/index.d.ts +0 -3
- package/admin/src/pages/NoAccessPage/index.js +0 -31
- package/admin/src/pages/Reports/components/ReportsTableRow/index.d.ts +0 -15
- package/admin/src/pages/Reports/components/ReportsTableRow/index.js +0 -91
- package/admin/src/pages/Reports/components/ReportsTableRow/styles.d.ts +0 -2
- package/admin/src/pages/Reports/components/ReportsTableRow/styles.js +0 -14
- package/admin/src/pages/Reports/index.d.ts +0 -11
- package/admin/src/pages/Reports/index.js +0 -196
- package/admin/src/pages/Reports/utils/api.d.ts +0 -2
- package/admin/src/pages/Reports/utils/api.js +0 -16
- package/admin/src/pages/Reports/utils/filtersSchema.d.ts +0 -26
- package/admin/src/pages/Reports/utils/filtersSchema.js +0 -32
- package/admin/src/pages/Settings/components/RestartAlert/styles.d.ts +0 -2
- package/admin/src/pages/Settings/components/RestartAlert/styles.js +0 -14
- package/admin/src/pages/Settings/index.d.ts +0 -3
- package/admin/src/pages/Settings/index.js +0 -244
- package/admin/src/pages/Settings/utils/api.d.ts +0 -7
- package/admin/src/pages/Settings/utils/api.js +0 -65
- package/admin/src/pages/utils/api.d.ts +0 -23
- package/admin/src/pages/utils/api.js +0 -85
- package/admin/src/permissions.js +0 -32
- package/admin/src/pluginId.js +0 -29
- package/admin/src/reducers.d.ts +0 -7
- package/admin/src/reducers.js +0 -12
- package/admin/src/translations/index.d.ts +0 -8
- package/admin/src/translations/index.js +0 -23
- package/admin/src/utils/axiosInstance.d.ts +0 -3
- package/admin/src/utils/axiosInstance.js +0 -29
- package/admin/src/utils/constants.d.ts +0 -29
- package/admin/src/utils/constants.js +0 -28
- package/admin/src/utils/errors.js +0 -10
- package/admin/src/utils/functions.js +0 -10
- package/admin/src/utils/getApiUrl.js +0 -6
- package/admin/src/utils/getMessage.d.ts +0 -4
- package/admin/src/utils/getMessage.js +0 -20
- package/admin/src/utils/getRelatedGroups.js +0 -5
- package/admin/src/utils/getUrl.js +0 -6
- package/admin/src/utils/handleAPIError.d.ts +0 -4
- package/admin/src/utils/handleAPIError.js +0 -17
- package/admin/src/utils/index.js +0 -40
- package/admin/src/utils/parseRegExp.js +0 -11
- package/admin/src/utils/renderEntryTitle.d.ts +0 -4
- package/admin/src/utils/renderEntryTitle.js +0 -13
- package/admin/src/utils/renderInitials.js +0 -11
- package/admin/src/utils/resolveCommentStatus.d.ts +0 -10
- package/admin/src/utils/resolveCommentStatus.js +0 -26
- package/admin/src/utils/resolveCommentStatusColor.d.ts +0 -4
- package/admin/src/utils/resolveCommentStatusColor.js +0 -22
- package/admin/src/utils/resolveReportStatus.d.ts +0 -4
- package/admin/src/utils/resolveReportStatus.js +0 -23
- package/admin/src/utils/resolveReportStatusColor.d.ts +0 -4
- package/admin/src/utils/resolveReportStatusColor.js +0 -17
- package/content-types/comment.js +0 -96
- package/content-types/index.js +0 -23
- package/content-types/report.js +0 -49
- package/permissions.js +0 -18
- package/server/bootstrap.d.ts +0 -4
- package/server/bootstrap.js +0 -59
- package/server/config/index.d.ts +0 -4
- package/server/config/index.js +0 -20
- package/server/controllers/admin.d.ts +0 -4
- package/server/controllers/admin.js +0 -212
- package/server/controllers/client.d.ts +0 -4
- package/server/controllers/client.js +0 -143
- package/server/controllers/index.d.ts +0 -6
- package/server/controllers/index.js +0 -13
- package/server/controllers/utils/functions.d.ts +0 -7
- package/server/controllers/utils/functions.js +0 -24
- package/server/controllers/utils/parsers.d.ts +0 -11
- package/server/controllers/utils/parsers.js +0 -72
- package/server/destroy.d.ts +0 -3
- package/server/destroy.js +0 -4
- package/server/graphql/index.d.ts +0 -4
- package/server/graphql/index.js +0 -27
- package/server/graphql/mutations/createAbuseReport.d.ts +0 -11
- package/server/graphql/mutations/createAbuseReport.js +0 -23
- package/server/graphql/mutations/createComment.d.ts +0 -14
- package/server/graphql/mutations/createComment.js +0 -23
- package/server/graphql/mutations/index.d.ts +0 -4
- package/server/graphql/mutations/index.js +0 -26
- package/server/graphql/mutations/removeComment.d.ts +0 -11
- package/server/graphql/mutations/removeComment.js +0 -23
- package/server/graphql/mutations/updateComment.d.ts +0 -11
- package/server/graphql/mutations/updateComment.js +0 -23
- package/server/graphql/queries/findAllFlat.d.ts +0 -19
- package/server/graphql/queries/findAllFlat.js +0 -37
- package/server/graphql/queries/findAllInHierarchy.d.ts +0 -18
- package/server/graphql/queries/findAllInHierarchy.js +0 -33
- package/server/graphql/queries/findAllPerAuthor.d.ts +0 -21
- package/server/graphql/queries/findAllPerAuthor.js +0 -40
- package/server/graphql/queries/index.d.ts +0 -4
- package/server/graphql/queries/index.js +0 -24
- package/server/graphql/resolvers-config.d.ts +0 -23
- package/server/graphql/resolvers-config.js +0 -13
- package/server/graphql/types/comment-author-type.d.ts +0 -4
- package/server/graphql/types/comment-author-type.js +0 -8
- package/server/graphql/types/comment-author.d.ts +0 -4
- package/server/graphql/types/comment-author.js +0 -11
- package/server/graphql/types/comment-nested.d.ts +0 -4
- package/server/graphql/types/comment-nested.js +0 -18
- package/server/graphql/types/comment.d.ts +0 -4
- package/server/graphql/types/comment.js +0 -17
- package/server/graphql/types/create-comment-author.d.ts +0 -4
- package/server/graphql/types/create-comment-author.js +0 -11
- package/server/graphql/types/create-comment.d.ts +0 -4
- package/server/graphql/types/create-comment.js +0 -11
- package/server/graphql/types/create-report.d.ts +0 -4
- package/server/graphql/types/create-report.js +0 -11
- package/server/graphql/types/id.d.ts +0 -4
- package/server/graphql/types/id.js +0 -25
- package/server/graphql/types/identify-comment-author.d.ts +0 -4
- package/server/graphql/types/identify-comment-author.js +0 -8
- package/server/graphql/types/index.d.ts +0 -4
- package/server/graphql/types/index.js +0 -42
- package/server/graphql/types/remove-comment.d.ts +0 -4
- package/server/graphql/types/remove-comment.js +0 -10
- package/server/graphql/types/report-reason.d.ts +0 -4
- package/server/graphql/types/report-reason.js +0 -12
- package/server/graphql/types/report.d.ts +0 -4
- package/server/graphql/types/report.js +0 -13
- package/server/graphql/types/response-find-all-per-author.d.ts +0 -4
- package/server/graphql/types/response-find-all-per-author.js +0 -9
- package/server/graphql/types/response-find-all.d.ts +0 -4
- package/server/graphql/types/response-find-all.js +0 -9
- package/server/graphql/types/response-meta.d.ts +0 -4
- package/server/graphql/types/response-meta.js +0 -8
- package/server/graphql/types/response-pagination.d.ts +0 -4
- package/server/graphql/types/response-pagination.js +0 -13
- package/server/graphql/types/update-comment.d.ts +0 -4
- package/server/graphql/types/update-comment.js +0 -11
- package/server/index.d.ts +0 -26
- package/server/index.js +0 -25
- package/server/register/custom-fields/comments.js +0 -9
- package/server/register/custom-fields/index.d.ts +0 -3
- package/server/register/custom-fields/index.js +0 -14
- package/server/register/index.js +0 -8
- package/server/routes/admin.d.ts +0 -4
- package/server/routes/admin.js +0 -182
- package/server/routes/client.d.ts +0 -4
- package/server/routes/client.js +0 -118
- package/server/routes/index.d.ts +0 -11
- package/server/routes/index.js +0 -19
- package/server/services/admin.d.ts +0 -5
- package/server/services/admin.js +0 -506
- package/server/services/client.d.ts +0 -5
- package/server/services/client.js +0 -321
- package/server/services/common.d.ts +0 -5
- package/server/services/common.js +0 -296
- package/server/services/graphql.d.ts +0 -5
- package/server/services/graphql.js +0 -150
- package/server/services/index.d.ts +0 -8
- package/server/services/index.js +0 -16
- package/server/services/utils/functions.d.ts +0 -14
- package/server/services/utils/functions.js +0 -118
- package/server/services/utils/parsers.d.ts +0 -6
- package/server/services/utils/parsers.js +0 -63
- package/server/utils/constants.d.ts +0 -15
- package/server/utils/constants.js +0 -47
- package/server/utils/error.js +0 -29
- package/server/utils/functions.d.ts +0 -10
- package/server/utils/functions.js +0 -53
- package/server/utils/types.js +0 -3
- package/strapi-admin.d.ts +0 -3
- package/strapi-admin.js +0 -8
- package/strapi-server.d.ts +0 -186
- package/strapi-server.js +0 -46
- package/tsconfig.tsbuildinfo +0 -1
- package/types/contentTypes.js +0 -3
- package/types/utils.d.ts +0 -5
- package/types/utils.js +0 -9
|
@@ -1,321 +0,0 @@
|
|
|
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
|
-
module.exports = ({ strapi }) => ({
|
|
11
|
-
getCommonService() {
|
|
12
|
-
return (0, functions_1.getPluginService)("common");
|
|
13
|
-
},
|
|
14
|
-
async create(relation, data, user) {
|
|
15
|
-
const { content, threadOf } = data;
|
|
16
|
-
const singleRelationFulfilled = relation && constants_1.REGEX.relatedUid.test(relation);
|
|
17
|
-
if (!singleRelationFulfilled) {
|
|
18
|
-
throw new error_1.default(400, `Field "related" got incorrect format, use format like "api::<collection name>.<content type name>:<entity id>"`);
|
|
19
|
-
}
|
|
20
|
-
const [uid, relatedId] = await this.getCommonService().parseRelationString(relation);
|
|
21
|
-
const enabledCollections = await this.getCommonService().getConfig(constants_1.CONFIG_PARAMS.ENABLED_COLLECTIONS, []);
|
|
22
|
-
const isEnabledCollection = await this.getCommonService().isEnabledCollection(uid);
|
|
23
|
-
if (enabledCollections.length > 0 && !isEnabledCollection) {
|
|
24
|
-
throw new error_1.default(400, `Field "related" refer to not enabled collection. Please amend the plugin settings and try again`);
|
|
25
|
-
}
|
|
26
|
-
const relatedEntity = await strapi.db
|
|
27
|
-
.query(uid)
|
|
28
|
-
.findOne({ where: { id: relatedId } });
|
|
29
|
-
if (!relatedEntity) {
|
|
30
|
-
throw new error_1.default(400, `Relation for field "related" does not exist. Check your payload please.`);
|
|
31
|
-
}
|
|
32
|
-
const approvalFlow = await this.getCommonService().getConfig(constants_1.CONFIG_PARAMS.APPROVAL_FLOW, []);
|
|
33
|
-
const isApprovalFlowEnabled = approvalFlow.includes(uid) || relatedEntity.requireCommentsApproval;
|
|
34
|
-
const doNotPopulateAuthor = await this.getCommonService().getConfig(constants_1.CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS, []);
|
|
35
|
-
let linkToThread;
|
|
36
|
-
try {
|
|
37
|
-
linkToThread = !(0, lodash_1.isNil)(threadOf)
|
|
38
|
-
? await this.getCommonService().findOne({
|
|
39
|
-
id: threadOf,
|
|
40
|
-
related: relation,
|
|
41
|
-
})
|
|
42
|
-
: null;
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
throw new error_1.default(400, "Thread does not exist");
|
|
46
|
-
}
|
|
47
|
-
const validContext = this.getCommonService().isValidUserContext(user);
|
|
48
|
-
if (!validContext) {
|
|
49
|
-
throw (0, functions_2.resolveUserContextError)(user);
|
|
50
|
-
}
|
|
51
|
-
if ((await this.getCommonService().checkBadWords(content)) &&
|
|
52
|
-
singleRelationFulfilled) {
|
|
53
|
-
const { author, ...rest } = data;
|
|
54
|
-
let authorData = {};
|
|
55
|
-
if (validContext && user) {
|
|
56
|
-
authorData = {
|
|
57
|
-
authorUser: user?.id,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
else if (author) {
|
|
61
|
-
if (author.email && !constants_1.REGEX.email.test(author.email)) {
|
|
62
|
-
throw new error_1.default(400, 'Field: "author.email". Author e-mail is not valid value. Check your payload');
|
|
63
|
-
}
|
|
64
|
-
authorData = {
|
|
65
|
-
authorId: author.id,
|
|
66
|
-
authorName: author.name,
|
|
67
|
-
authorEmail: author.email,
|
|
68
|
-
authorAvatar: (0, lodash_1.isString)(author.avatar) ? author.avatar : undefined,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
const authorNotProperlyProvided = !(0, lodash_1.isEmpty)(authorData) && !(authorData.authorId || authorData.authorUser);
|
|
72
|
-
if ((0, lodash_1.isEmpty)(authorData) || authorNotProperlyProvided) {
|
|
73
|
-
throw new error_1.default(400, `Not able to recognise author of a comment. Make sure you've provided "author" property in a payload or authenticated your request properly.`);
|
|
74
|
-
}
|
|
75
|
-
if (isApprovalFlowEnabled &&
|
|
76
|
-
!(0, lodash_1.isNil)(data.approvalStatus) &&
|
|
77
|
-
data.approvalStatus !== constants_1.APPROVAL_STATUS.PENDING) {
|
|
78
|
-
throw new error_1.default(400, "Invalid approval status");
|
|
79
|
-
}
|
|
80
|
-
const entity = await strapi.db
|
|
81
|
-
.query((0, functions_2.getModelUid)("comment"))
|
|
82
|
-
.create({
|
|
83
|
-
data: {
|
|
84
|
-
...rest,
|
|
85
|
-
...authorData,
|
|
86
|
-
related: relation,
|
|
87
|
-
approvalStatus: isApprovalFlowEnabled
|
|
88
|
-
? constants_1.APPROVAL_STATUS.PENDING
|
|
89
|
-
: null,
|
|
90
|
-
},
|
|
91
|
-
populate: {
|
|
92
|
-
authorUser: true,
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
const sanitizedEntity = this.getCommonService().sanitizeCommentEntity({
|
|
96
|
-
...entity,
|
|
97
|
-
threadOf: linkToThread,
|
|
98
|
-
}, doNotPopulateAuthor);
|
|
99
|
-
try {
|
|
100
|
-
await this.sendResponseNotification(sanitizedEntity);
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
console.error(e);
|
|
104
|
-
}
|
|
105
|
-
return sanitizedEntity;
|
|
106
|
-
}
|
|
107
|
-
throw new error_1.default(400, "No content received");
|
|
108
|
-
},
|
|
109
|
-
async update(id, relation, data, user) {
|
|
110
|
-
const { content } = data;
|
|
111
|
-
const singleRelationFulfilled = relation && constants_1.REGEX.relatedUid.test(relation);
|
|
112
|
-
if (!singleRelationFulfilled) {
|
|
113
|
-
throw new error_1.default(400, `Request property "relation" got incorrect format, use format like "api::<collection name>.<content type name>:<entity id>"`);
|
|
114
|
-
}
|
|
115
|
-
await this.getCommonService().parseRelationString(relation);
|
|
116
|
-
const existingEntity = await this.getCommonService().findOne({
|
|
117
|
-
id,
|
|
118
|
-
related: relation,
|
|
119
|
-
});
|
|
120
|
-
const validContext = this.getCommonService().isValidUserContext(user);
|
|
121
|
-
if (!validContext) {
|
|
122
|
-
throw (0, functions_2.resolveUserContextError)(user);
|
|
123
|
-
}
|
|
124
|
-
if ((0, functions_2.isEqualEntity)(existingEntity, data, user) && content) {
|
|
125
|
-
if (await this.getCommonService().checkBadWords(content)) {
|
|
126
|
-
const blockedAuthorProps = await this.getCommonService().getConfig(constants_1.CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS, []);
|
|
127
|
-
const entity = await strapi.db
|
|
128
|
-
.query((0, functions_2.getModelUid)("comment"))
|
|
129
|
-
.update({
|
|
130
|
-
where: { id },
|
|
131
|
-
data: { content },
|
|
132
|
-
populate: { threadOf: true, authorUser: true },
|
|
133
|
-
});
|
|
134
|
-
return this.getCommonService().sanitizeCommentEntity(entity, blockedAuthorProps);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
throw new error_1.default(403, `You're not allowed to take an action on that entity. Make sure you've provided "author" property in a payload or authenticated your request properly.`);
|
|
138
|
-
},
|
|
139
|
-
async reportAbuse(id, relation, payload, user) {
|
|
140
|
-
if (!this.getCommonService().isValidUserContext(user)) {
|
|
141
|
-
throw (0, functions_2.resolveUserContextError)(user);
|
|
142
|
-
}
|
|
143
|
-
await this.getCommonService().parseRelationString(relation);
|
|
144
|
-
try {
|
|
145
|
-
const reportAgainstEntity = await this.getCommonService().findOne({
|
|
146
|
-
id,
|
|
147
|
-
related: relation,
|
|
148
|
-
});
|
|
149
|
-
if (reportAgainstEntity.isAdminComment) {
|
|
150
|
-
throw new error_1.default(403, `You're not allowed to take an action on that entity. This in a admin comment.`);
|
|
151
|
-
}
|
|
152
|
-
if (reportAgainstEntity) {
|
|
153
|
-
const entity = await strapi.db
|
|
154
|
-
.query((0, functions_2.getModelUid)("comment-report"))
|
|
155
|
-
.create({
|
|
156
|
-
data: {
|
|
157
|
-
...payload,
|
|
158
|
-
resolved: false,
|
|
159
|
-
related: id,
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
if (entity) {
|
|
163
|
-
const response = {
|
|
164
|
-
...entity,
|
|
165
|
-
related: reportAgainstEntity,
|
|
166
|
-
};
|
|
167
|
-
try {
|
|
168
|
-
await this.sendAbuseReportEmail(entity.reason, entity.content);
|
|
169
|
-
return response;
|
|
170
|
-
}
|
|
171
|
-
catch (err) {
|
|
172
|
-
return response;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
throw new error_1.default(500, "Report cannot be created");
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
throw new error_1.default(403, `You're not allowed to take an action on that entity. Make sure that comment exist or you've authenticated your request properly.`);
|
|
180
|
-
}
|
|
181
|
-
catch (e) {
|
|
182
|
-
throw e;
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
async markAsRemoved(id, relation, authorId, user) {
|
|
186
|
-
if (!this.getCommonService().isValidUserContext(user)) {
|
|
187
|
-
throw (0, functions_2.resolveUserContextError)(user);
|
|
188
|
-
}
|
|
189
|
-
const author = user?.id || authorId;
|
|
190
|
-
if (!author) {
|
|
191
|
-
throw new error_1.default(403, `You're not allowed to take an action on that entity. Make sure that you've provided proper "authorId" or authenticated your request properly.`);
|
|
192
|
-
}
|
|
193
|
-
await this.getCommonService().parseRelationString(relation);
|
|
194
|
-
try {
|
|
195
|
-
const byAuthor = user?.id
|
|
196
|
-
? {
|
|
197
|
-
authorUser: author,
|
|
198
|
-
}
|
|
199
|
-
: {
|
|
200
|
-
authorId: author,
|
|
201
|
-
};
|
|
202
|
-
const entity = await this.getCommonService().findOne({
|
|
203
|
-
id,
|
|
204
|
-
related: relation,
|
|
205
|
-
...byAuthor,
|
|
206
|
-
});
|
|
207
|
-
if (entity) {
|
|
208
|
-
const removedEntity = await strapi.db
|
|
209
|
-
.query((0, functions_2.getModelUid)("comment"))
|
|
210
|
-
.update({
|
|
211
|
-
where: {
|
|
212
|
-
id,
|
|
213
|
-
related: relation,
|
|
214
|
-
},
|
|
215
|
-
data: { removed: true },
|
|
216
|
-
populate: { threadOf: true, authorUser: true },
|
|
217
|
-
});
|
|
218
|
-
await this.markAsRemovedNested(id, true);
|
|
219
|
-
const doNotPopulateAuthor = await this.getCommonService().getConfig(constants_1.CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS, []);
|
|
220
|
-
return this.getCommonService().sanitizeCommentEntity(removedEntity, doNotPopulateAuthor);
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
throw new error_1.default(404, `Entity does not exist or you're not allowed to take an action on it`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
catch (e) {
|
|
227
|
-
throw new error_1.default(404, `Entity does not exist or you're not allowed to take an action on it`);
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
async sendAbuseReportEmail(reason, content) {
|
|
231
|
-
const rolesToBeNotified = (await this.getCommonService().getConfig(constants_1.CONFIG_PARAMS.MODERATOR_ROLES)) || ["strapi-super-admin"];
|
|
232
|
-
const adminUserModel = strapi.db.query("admin::user");
|
|
233
|
-
const emails = await adminUserModel
|
|
234
|
-
.findMany({
|
|
235
|
-
where: {
|
|
236
|
-
roles: { code: rolesToBeNotified },
|
|
237
|
-
},
|
|
238
|
-
})
|
|
239
|
-
.then((items) => items.map((_) => _.email));
|
|
240
|
-
const superAdmin = await strapi.db
|
|
241
|
-
.query("admin::user")
|
|
242
|
-
.findOne({
|
|
243
|
-
where: {
|
|
244
|
-
roles: { code: "strapi-super-admin" },
|
|
245
|
-
},
|
|
246
|
-
});
|
|
247
|
-
if (emails.length > 0) {
|
|
248
|
-
try {
|
|
249
|
-
await strapi
|
|
250
|
-
.plugin("email")
|
|
251
|
-
.service("email")
|
|
252
|
-
.send({
|
|
253
|
-
to: emails,
|
|
254
|
-
from: superAdmin.email,
|
|
255
|
-
subject: "New abuse report on comment",
|
|
256
|
-
text: `
|
|
257
|
-
There was a new abuse report on your app.
|
|
258
|
-
Reason: ${reason}
|
|
259
|
-
Message: ${content}
|
|
260
|
-
`,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
catch (err) {
|
|
264
|
-
strapi.log.error(err);
|
|
265
|
-
throw err;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
async markAsRemovedNested(id, status) {
|
|
270
|
-
return this.getCommonService().modifiedNestedNestedComments(id, "removed", status);
|
|
271
|
-
},
|
|
272
|
-
async sendResponseNotification(entity) {
|
|
273
|
-
if (entity.threadOf) {
|
|
274
|
-
const thread = (0, lodash_1.isObject)(entity.threadOf) ? entity.threadOf : await this.getCommonService().findOne({ id: entity.threadOf });
|
|
275
|
-
let emailRecipient = thread?.author?.email;
|
|
276
|
-
if (thread.authorUser && !emailRecipient) {
|
|
277
|
-
const strapiUser = (0, lodash_1.isObject)(thread.authorUser) ? thread.authorUser : await strapi.db.query("api::user").findOne({
|
|
278
|
-
where: { id: thread.authorUser }
|
|
279
|
-
});
|
|
280
|
-
emailRecipient = strapiUser?.email;
|
|
281
|
-
}
|
|
282
|
-
if (emailRecipient) {
|
|
283
|
-
const superAdmin = await strapi.db
|
|
284
|
-
.query("admin::user")
|
|
285
|
-
.findOne({
|
|
286
|
-
where: {
|
|
287
|
-
roles: { code: "strapi-super-admin" },
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
const emailSender = await this.getCommonService().getConfig('client.contactEmail', superAdmin.email);
|
|
291
|
-
const clientAppUrl = await this.getCommonService().getConfig('client.url', 'our site');
|
|
292
|
-
try {
|
|
293
|
-
await strapi
|
|
294
|
-
.plugin("email")
|
|
295
|
-
.service("email")
|
|
296
|
-
.send({
|
|
297
|
-
to: [emailRecipient],
|
|
298
|
-
from: emailSender,
|
|
299
|
-
subject: "You've got a new response to your comment",
|
|
300
|
-
text: `Hello ${thread?.author?.name || emailRecipient}!
|
|
301
|
-
You've got a new response to your comment by ${entity?.author?.name || entity?.author?.email}.
|
|
302
|
-
|
|
303
|
-
------
|
|
304
|
-
|
|
305
|
-
"${entity.content}"
|
|
306
|
-
|
|
307
|
-
------
|
|
308
|
-
|
|
309
|
-
Visit ${clientAppUrl} and continue the discussion.
|
|
310
|
-
`,
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
catch (err) {
|
|
314
|
-
strapi.log.error(err);
|
|
315
|
-
throw err;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
});
|
|
321
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
const no_profanity_1 = require("no-profanity");
|
|
6
|
-
const lodash_1 = require("lodash");
|
|
7
|
-
const constants_1 = require("../utils/constants");
|
|
8
|
-
const error_1 = __importDefault(require("./../utils/error"));
|
|
9
|
-
const functions_1 = require("./utils/functions");
|
|
10
|
-
const parsers_1 = require("./utils/parsers");
|
|
11
|
-
const PAGE_SIZE = 10;
|
|
12
|
-
const REQUIRED_FIELDS = ["id"];
|
|
13
|
-
const lifecycleHookListeners = {
|
|
14
|
-
comment: {},
|
|
15
|
-
"comment-report": {}
|
|
16
|
-
};
|
|
17
|
-
module.exports = ({ strapi }) => ({
|
|
18
|
-
async getConfig(prop, defaultValue, useLocal = false) {
|
|
19
|
-
const queryProp = (0, functions_1.buildConfigQueryProp)(prop);
|
|
20
|
-
const pluginStore = await this.getPluginStore();
|
|
21
|
-
const config = await pluginStore.get({
|
|
22
|
-
key: "config",
|
|
23
|
-
});
|
|
24
|
-
let result;
|
|
25
|
-
if (config && !useLocal) {
|
|
26
|
-
result = queryProp ? (0, lodash_1.get)(config, queryProp, defaultValue) : config;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
result = this.getLocalConfig(queryProp, defaultValue);
|
|
30
|
-
}
|
|
31
|
-
return (0, lodash_1.isNil)(result) ? defaultValue : result;
|
|
32
|
-
},
|
|
33
|
-
async getPluginStore() {
|
|
34
|
-
return strapi.store({ type: "plugin", name: "comments" });
|
|
35
|
-
},
|
|
36
|
-
getLocalConfig(prop, defaultValue) {
|
|
37
|
-
const queryProp = (0, functions_1.buildConfigQueryProp)(prop);
|
|
38
|
-
const result = strapi.config.get(`plugin.comments${queryProp ? "." + queryProp : ""}`);
|
|
39
|
-
return (0, lodash_1.isNil)(result) ? defaultValue : result;
|
|
40
|
-
},
|
|
41
|
-
async findAllFlat({ query = {}, populate = {}, sort, pagination, fields, isAdmin = false, omit: baseOmit = [], }, relatedEntity = null) {
|
|
42
|
-
const omit = baseOmit.filter((field) => !REQUIRED_FIELDS.includes(field));
|
|
43
|
-
const defaultSelect = ["id", "related"].filter((field) => !omit.includes(field));
|
|
44
|
-
const populateClause = {
|
|
45
|
-
authorUser: true,
|
|
46
|
-
...((0, lodash_1.isObject)(populate) ? populate : {}),
|
|
47
|
-
};
|
|
48
|
-
const doNotPopulateAuthor = isAdmin
|
|
49
|
-
? []
|
|
50
|
-
: await this.getConfig(constants_1.CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS, []);
|
|
51
|
-
const sortQuery = (0, parsers_1.parseSortQuery)(sort);
|
|
52
|
-
const fieldsQuery = (0, parsers_1.parseFieldsQuery)(fields, sortQuery, defaultSelect);
|
|
53
|
-
let [meta, queryExtension = {}] = (0, parsers_1.parsePaginationsQuery)(pagination, fieldsQuery, { PAGE_SIZE });
|
|
54
|
-
const entries = await strapi.db
|
|
55
|
-
.query((0, functions_1.getModelUid)("comment"))
|
|
56
|
-
.findMany({
|
|
57
|
-
where: {
|
|
58
|
-
...query,
|
|
59
|
-
},
|
|
60
|
-
populate: {
|
|
61
|
-
...populateClause,
|
|
62
|
-
},
|
|
63
|
-
...queryExtension,
|
|
64
|
-
});
|
|
65
|
-
if (pagination?.withCount &&
|
|
66
|
-
(pagination.withCount === "true" || pagination.withCount === true)) {
|
|
67
|
-
const total = await strapi.db
|
|
68
|
-
.query((0, functions_1.getModelUid)("comment"))
|
|
69
|
-
.count({
|
|
70
|
-
where: {
|
|
71
|
-
...query,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
const pageSize = meta.pagination.pageSize || PAGE_SIZE;
|
|
75
|
-
const pageCount = Math.floor(total / pageSize);
|
|
76
|
-
meta = {
|
|
77
|
-
...meta,
|
|
78
|
-
pagination: {
|
|
79
|
-
...meta.pagination,
|
|
80
|
-
pageCount: !(0, lodash_1.isNil)(meta.pagination.page)
|
|
81
|
-
? total % pageSize === 0
|
|
82
|
-
? pageCount
|
|
83
|
-
: pageCount + 1
|
|
84
|
-
: undefined,
|
|
85
|
-
total,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
const entriesWithThreads = await Promise.all(entries.map(async (_) => {
|
|
90
|
-
const [nestedEntries, count] = await strapi.db
|
|
91
|
-
.query((0, functions_1.getModelUid)("comment"))
|
|
92
|
-
.findWithCount({
|
|
93
|
-
where: {
|
|
94
|
-
threadOf: _.id,
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
return {
|
|
98
|
-
id: _.id,
|
|
99
|
-
itemsInTread: count,
|
|
100
|
-
firstThreadItemId: (0, lodash_1.first)(nestedEntries)?.id,
|
|
101
|
-
};
|
|
102
|
-
}));
|
|
103
|
-
const relatedEntities = omit.includes("related")
|
|
104
|
-
? []
|
|
105
|
-
: relatedEntity !== null
|
|
106
|
-
? [relatedEntity]
|
|
107
|
-
: await this.findRelatedEntitiesFor([...entries]);
|
|
108
|
-
const hasRelatedEntitiesToMap = relatedEntities.filter((_) => _).length > 0;
|
|
109
|
-
const result = entries.map((_) => {
|
|
110
|
-
const threadedItem = entriesWithThreads.find((item) => item.id === _.id);
|
|
111
|
-
const parsedThreadOf = (0, lodash_1.isString)(query.threadOf)
|
|
112
|
-
? (0, lodash_1.parseInt)(query.threadOf)
|
|
113
|
-
: query.threadOf;
|
|
114
|
-
let authorUserPopulate = {};
|
|
115
|
-
if ((0, lodash_1.isObject)(populateClause?.authorUser)) {
|
|
116
|
-
authorUserPopulate =
|
|
117
|
-
"populate" in populateClause.authorUser
|
|
118
|
-
? populateClause.authorUser.populate
|
|
119
|
-
: populateClause.authorUser;
|
|
120
|
-
}
|
|
121
|
-
const primitiveThreadOf = (0, lodash_1.isString)(parsedThreadOf) || (0, lodash_1.isNumber)(parsedThreadOf) ?
|
|
122
|
-
parsedThreadOf :
|
|
123
|
-
null;
|
|
124
|
-
return this.sanitizeCommentEntity({
|
|
125
|
-
..._,
|
|
126
|
-
threadOf: primitiveThreadOf || _.threadOf,
|
|
127
|
-
gotThread: (threadedItem?.itemsInTread || 0) > 0,
|
|
128
|
-
threadFirstItemId: threadedItem?.firstThreadItemId,
|
|
129
|
-
}, doNotPopulateAuthor, omit, authorUserPopulate);
|
|
130
|
-
});
|
|
131
|
-
return {
|
|
132
|
-
data: hasRelatedEntitiesToMap
|
|
133
|
-
? result.map((_) => this.mergeRelatedEntityTo(_, relatedEntities))
|
|
134
|
-
: result,
|
|
135
|
-
...((0, lodash_1.isEmpty)(meta) ? {} : { meta }),
|
|
136
|
-
};
|
|
137
|
-
},
|
|
138
|
-
async findAllInHierarchy({ query, populate = {}, sort, fields, startingFromId = null, dropBlockedThreads = false, isAdmin = false, omit = [], }, relatedEntity) {
|
|
139
|
-
const entities = await this.findAllFlat({ query, populate, sort, fields, isAdmin, omit }, relatedEntity);
|
|
140
|
-
return (0, functions_1.buildNestedStructure)(entities?.data, startingFromId, "threadOf", dropBlockedThreads, false);
|
|
141
|
-
},
|
|
142
|
-
async findOne(criteria) {
|
|
143
|
-
const entity = await strapi.db
|
|
144
|
-
.query((0, functions_1.getModelUid)("comment"))
|
|
145
|
-
.findOne({
|
|
146
|
-
where: criteria,
|
|
147
|
-
populate: {
|
|
148
|
-
reports: true,
|
|
149
|
-
authorUser: true,
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
if (!entity) {
|
|
153
|
-
throw new error_1.default(404, "Comment does not exist. Check your payload please.");
|
|
154
|
-
}
|
|
155
|
-
const doNotPopulateAuthor = await this.getConfig(constants_1.CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS, []);
|
|
156
|
-
return (0, functions_1.filterOurResolvedReports)(this.sanitizeCommentEntity(entity, doNotPopulateAuthor));
|
|
157
|
-
},
|
|
158
|
-
async findAllPerAuthor({ query = {}, populate = {}, pagination, sort, fields, isAdmin = false, }, authorId, isStrapiAuthor = false) {
|
|
159
|
-
if ((0, lodash_1.isNil)(authorId)) {
|
|
160
|
-
return {
|
|
161
|
-
data: [],
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
const { related, ...restQuery } = query;
|
|
165
|
-
const authorQuery = isStrapiAuthor ? {
|
|
166
|
-
authorUser: {
|
|
167
|
-
id: authorId
|
|
168
|
-
},
|
|
169
|
-
} : {
|
|
170
|
-
authorId,
|
|
171
|
-
};
|
|
172
|
-
const response = await this.findAllFlat({
|
|
173
|
-
query: {
|
|
174
|
-
...restQuery,
|
|
175
|
-
...authorQuery,
|
|
176
|
-
},
|
|
177
|
-
pagination, populate, sort, fields, isAdmin
|
|
178
|
-
});
|
|
179
|
-
return {
|
|
180
|
-
...response,
|
|
181
|
-
data: response.data.map(({ author, ...rest }) => rest),
|
|
182
|
-
};
|
|
183
|
-
},
|
|
184
|
-
async findRelatedEntitiesFor(entities = []) {
|
|
185
|
-
const data = entities.reduce((acc, curr) => {
|
|
186
|
-
const [relatedUid, relatedStringId] = (0, functions_1.getRelatedGroups)(curr.related);
|
|
187
|
-
const parsedRelatedId = (0, lodash_1.parseInt)(relatedStringId);
|
|
188
|
-
const relatedId = (0, lodash_1.isNumber)(parsedRelatedId)
|
|
189
|
-
? parsedRelatedId
|
|
190
|
-
: relatedStringId;
|
|
191
|
-
return {
|
|
192
|
-
...acc,
|
|
193
|
-
[relatedUid]: [...(acc[relatedUid] || []), relatedId],
|
|
194
|
-
};
|
|
195
|
-
}, {});
|
|
196
|
-
return Promise.all(Object.entries(data).map(async ([relatedUid, relatedStringIds]) => strapi.db
|
|
197
|
-
.query(relatedUid)
|
|
198
|
-
.findMany({
|
|
199
|
-
where: { id: Array.from(new Set(relatedStringIds)) },
|
|
200
|
-
})
|
|
201
|
-
.then((relatedEntities) => relatedEntities.map((_) => ({
|
|
202
|
-
..._,
|
|
203
|
-
uid: relatedUid,
|
|
204
|
-
}))))).then((result) => result.flat(2));
|
|
205
|
-
},
|
|
206
|
-
mergeRelatedEntityTo(entity, relatedEntities = []) {
|
|
207
|
-
return {
|
|
208
|
-
...entity,
|
|
209
|
-
related: relatedEntities.find((relatedEntity) => entity.related === `${relatedEntity.uid}:${relatedEntity.id}`),
|
|
210
|
-
};
|
|
211
|
-
},
|
|
212
|
-
async modifiedNestedNestedComments(id, fieldName, value) {
|
|
213
|
-
try {
|
|
214
|
-
const entitiesToChange = await strapi.db
|
|
215
|
-
.query((0, functions_1.getModelUid)("comment"))
|
|
216
|
-
.findMany({
|
|
217
|
-
where: { threadOf: id },
|
|
218
|
-
});
|
|
219
|
-
const changedEntities = await strapi.db
|
|
220
|
-
.query((0, functions_1.getModelUid)("comment"))
|
|
221
|
-
.updateMany({
|
|
222
|
-
where: { id: entitiesToChange.map((_) => _.id) },
|
|
223
|
-
data: { [fieldName]: value },
|
|
224
|
-
});
|
|
225
|
-
if (entitiesToChange.length === changedEntities.count &&
|
|
226
|
-
changedEntities.count > 0) {
|
|
227
|
-
const nestedTransactions = await Promise.all(entitiesToChange.map((item) => this.modifiedNestedNestedComments(item.id, fieldName, value)));
|
|
228
|
-
return nestedTransactions.length === changedEntities.count;
|
|
229
|
-
}
|
|
230
|
-
return true;
|
|
231
|
-
}
|
|
232
|
-
catch (e) {
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
sanitizeCommentEntity(entity, blockedAuthorProps, omit = [], populate) {
|
|
237
|
-
const fieldsToPopulate = (0, lodash_1.isArray)(populate)
|
|
238
|
-
? populate
|
|
239
|
-
: Object.keys(populate || {});
|
|
240
|
-
return (0, lodash_1.omit)({
|
|
241
|
-
...(0, functions_1.buildAuthorModel)({
|
|
242
|
-
...entity,
|
|
243
|
-
threadOf: (0, lodash_1.isObject)(entity.threadOf)
|
|
244
|
-
? (0, functions_1.buildAuthorModel)(entity.threadOf, blockedAuthorProps, fieldsToPopulate)
|
|
245
|
-
: entity.threadOf,
|
|
246
|
-
}, blockedAuthorProps, fieldsToPopulate),
|
|
247
|
-
}, omit);
|
|
248
|
-
},
|
|
249
|
-
isValidUserContext(user) {
|
|
250
|
-
return user ? !(0, lodash_1.isNil)(user?.id) : true;
|
|
251
|
-
},
|
|
252
|
-
async parseRelationString(relation) {
|
|
253
|
-
const [uid, relatedStringId] = (0, functions_1.getRelatedGroups)(relation);
|
|
254
|
-
const parsedRelatedId = (0, lodash_1.parseInt)(relatedStringId);
|
|
255
|
-
const relatedId = (0, lodash_1.isNumber)(parsedRelatedId)
|
|
256
|
-
? parsedRelatedId
|
|
257
|
-
: relatedStringId;
|
|
258
|
-
const isEnabledCollection = await this.isEnabledCollection(uid);
|
|
259
|
-
const enabledCollections = await this.getConfig(constants_1.CONFIG_PARAMS.ENABLED_COLLECTIONS, []);
|
|
260
|
-
if (enabledCollections.length > 0 && !isEnabledCollection) {
|
|
261
|
-
throw new error_1.default(403, `Action not allowed for collection '${uid}'. Use one of: ${enabledCollections.join(", ")}`);
|
|
262
|
-
}
|
|
263
|
-
return [uid, relatedId];
|
|
264
|
-
},
|
|
265
|
-
async checkBadWords(content) {
|
|
266
|
-
const config = await this.getConfig(constants_1.CONFIG_PARAMS.BAD_WORDS, true);
|
|
267
|
-
if (config) {
|
|
268
|
-
if (content && (0, no_profanity_1.isProfane)({ testString: content })) {
|
|
269
|
-
throw new error_1.default(400, "Bad language used! Please polite your comment...", {
|
|
270
|
-
content: {
|
|
271
|
-
original: content,
|
|
272
|
-
filtered: content && (0, no_profanity_1.replaceProfanities)({ testString: content }),
|
|
273
|
-
},
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return content;
|
|
278
|
-
},
|
|
279
|
-
async isEnabledCollection(uid) {
|
|
280
|
-
const enabledCollections = await this.getConfig("enabledCollections", []);
|
|
281
|
-
return enabledCollections.includes(uid);
|
|
282
|
-
},
|
|
283
|
-
registerLifecycleHook({ callback, contentTypeName, hookName }) {
|
|
284
|
-
if (!lifecycleHookListeners[contentTypeName][hookName]) {
|
|
285
|
-
lifecycleHookListeners[contentTypeName][hookName] = [];
|
|
286
|
-
}
|
|
287
|
-
lifecycleHookListeners[contentTypeName][hookName]?.push(callback);
|
|
288
|
-
},
|
|
289
|
-
async runLifecycleHook({ contentTypeName, event, hookName }) {
|
|
290
|
-
const hookListeners = lifecycleHookListeners[contentTypeName][hookName] ?? [];
|
|
291
|
-
for (const listener of hookListeners) {
|
|
292
|
-
await listener(event);
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
});
|
|
296
|
-
//# sourceMappingURL=common.js.map
|