strapi-plugin-comments 2.2.1 → 2.2.3
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 +1 -1
- package/admin/src/components/ActionButton/styles.d.ts +1 -1
- package/admin/src/components/AdminAvatar/index.d.ts +4 -0
- package/admin/src/components/AdminAvatar/index.js +17 -0
- package/admin/src/components/AdminAvatar/styles.d.ts +3 -0
- package/admin/src/components/AdminAvatar/styles.js +17 -0
- package/admin/src/components/Avatar/index.d.ts +8 -11
- package/admin/src/components/Avatar/index.js +7 -8
- package/admin/src/components/DiscussionThreadItem/styles.d.ts +3 -3
- package/admin/src/components/DiscussionThreadItemActions/styles.d.ts +1 -1
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.d.ts +1 -1
- package/admin/src/components/DiscussionThreadItemFooter/styles.d.ts +2 -2
- package/admin/src/components/FormSwitch/styles.d.ts +1 -1
- package/admin/src/components/Hint/index.d.ts +1 -1
- package/admin/src/components/IconButton/styles.d.ts +1 -1
- package/admin/src/components/LoadingIndicatorOverlay/styles.d.ts +2 -2
- package/admin/src/components/ModeratorResponse/index.d.ts +1 -1
- package/admin/src/components/ModeratorResponse/styles.d.ts +1 -1
- package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.d.ts +1 -1
- package/admin/src/components/PreviewWysiwyg/Wrapper.d.ts +1 -1
- package/admin/src/components/PreviewWysiwyg/index.d.ts +1 -1
- package/admin/src/components/StatusBadge/styles.d.ts +1 -1
- package/admin/src/components/Wysiwyg/Editor.d.ts +1 -1
- package/admin/src/components/Wysiwyg/EditorLayout.d.ts +2 -2
- package/admin/src/components/Wysiwyg/EditorStylesContainer.d.ts +1 -1
- package/admin/src/components/Wysiwyg/WysiwygFooter.d.ts +1 -1
- package/admin/src/components/Wysiwyg/WysiwygNav.d.ts +1 -1
- package/admin/src/components/Wysiwyg/WysiwygStyles.d.ts +7 -7
- package/admin/src/components/Wysiwyg/index.d.ts +1 -1
- package/admin/src/components/icons/strapiIcons.d.ts +1 -0
- package/admin/src/components/icons/strapiIcons.js +2 -1
- package/admin/src/custom-fields/comments/components/input/consts.d.ts +3 -0
- package/admin/src/custom-fields/comments/components/input/consts.js +9 -0
- package/admin/src/custom-fields/comments/components/input/input.js +2 -6
- package/admin/src/custom-fields/comments/components/input/types.d.ts +2 -2
- package/admin/src/custom-fields/comments/components/input/utils.js +8 -1
- package/admin/src/index.js +2 -1
- package/admin/src/pages/Details/components/DetailsFilters/styles.d.ts +1 -1
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +12 -11
- package/admin/src/pages/Discover/components/DiscoverTableRow/styles.d.ts +1 -1
- package/admin/src/pages/Discover/utils/filtersSchema.d.ts +17 -2
- package/admin/src/pages/Discover/utils/filtersSchema.js +28 -0
- package/admin/src/pages/Reports/components/ReportsTableRow/styles.d.ts +1 -1
- package/admin/src/pages/Reports/utils/filtersSchema.d.ts +17 -2
- package/admin/src/pages/Reports/utils/filtersSchema.js +21 -0
- package/admin/src/pages/Settings/components/RestartAlert/styles.d.ts +1 -1
- package/admin/src/utils/getRelatedGroups.d.ts +1 -1
- package/admin/src/utils/resolveCommentStatus.d.ts +1 -1
- package/content-types/comment.d.ts +4 -0
- package/content-types/comment.js +4 -0
- package/content-types/index.d.ts +4 -0
- package/package.json +6 -4
- package/server/controllers/index.d.ts +1 -1
- package/server/controllers/utils/functions.d.ts +1 -1
- package/server/graphql/mutations/createComment.d.ts +1 -1
- package/server/graphql/queries/findAllFlat.d.ts +1 -1
- package/server/graphql/queries/findAllInHierarchy.d.ts +1 -1
- package/server/routes/index.d.ts +2 -2
- package/server/services/admin.js +33 -14
- package/server/services/client.js +4 -1
- package/server/services/utils/functions.d.ts +2 -1
- package/server/services/utils/functions.js +9 -1
- package/server/utils/error.d.ts +1 -1
- package/strapi-server.d.ts +4 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/types/contentTypes.d.ts +10 -9
- package/types/utils.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-comments",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "Strapi - Comments plugin",
|
|
5
5
|
"strapi": {
|
|
6
6
|
"name": "comments",
|
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
"url": "https://github.com/VirtusLab-Open-Source/strapi-plugin-comments"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@strapi/plugin-graphql": "^4.4
|
|
18
|
-
"@strapi/utils": "^4.4
|
|
17
|
+
"@strapi/plugin-graphql": "^4.5.4",
|
|
18
|
+
"@strapi/utils": "^4.5.4",
|
|
19
19
|
"@types/axios": "^0.14.0",
|
|
20
20
|
"@types/react-intl": "^3.0.0",
|
|
21
21
|
"@types/react-query": "^1.2.9",
|
|
22
|
-
"
|
|
22
|
+
"@types/styled-components": "^5.1.26",
|
|
23
|
+
"bad-words": "^3.0.4",
|
|
24
|
+
"styled-components": "^5.3.6"
|
|
23
25
|
},
|
|
24
26
|
"devDependencies": {},
|
|
25
27
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Id, StringMap, StrapiRequestContext } from "strapi-typed";
|
|
2
2
|
import PluginError from "../../utils/error";
|
|
3
|
-
|
|
3
|
+
type ParseResponse = StringMap<string | number | Id>;
|
|
4
4
|
export declare const parseParams: <T extends ParseResponse>(params: StringMap<string | number>) => T;
|
|
5
5
|
export declare const throwError: <T extends {} = never>(ctx: StrapiRequestContext<T, StringMap<string | number>, StringMap<string | number>>, e: PluginError | Error | unknown) => PluginError | Error | unknown | never;
|
|
6
6
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StrapiRequestContext } from "strapi-typed";
|
|
2
2
|
import { StrapiGraphQLContext, ToBeFixed } from "../../../types";
|
|
3
|
-
|
|
3
|
+
type CreateCommentProps = {
|
|
4
4
|
input: ToBeFixed;
|
|
5
5
|
};
|
|
6
6
|
declare const _default: ({ nexus }: StrapiGraphQLContext) => {
|
package/server/routes/index.d.ts
CHANGED
package/server/services/admin.js
CHANGED
|
@@ -94,19 +94,25 @@ module.exports = ({ strapi }) => ({
|
|
|
94
94
|
},
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
+
const basePopulate = {
|
|
98
|
+
threadOf: true,
|
|
99
|
+
reports: {
|
|
100
|
+
where: {
|
|
101
|
+
resolved: false,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
const populate = defaultAuthorUserPopulate
|
|
106
|
+
? {
|
|
107
|
+
...basePopulate,
|
|
108
|
+
authorUser: defaultAuthorUserPopulate,
|
|
109
|
+
}
|
|
110
|
+
: basePopulate;
|
|
97
111
|
const entities = await strapi.db
|
|
98
112
|
.query((0, functions_2.getModelUid)("comment"))
|
|
99
113
|
.findMany({
|
|
100
114
|
...params,
|
|
101
|
-
populate
|
|
102
|
-
authorUser: defaultAuthorUserPopulate,
|
|
103
|
-
threadOf: true,
|
|
104
|
-
reports: {
|
|
105
|
-
where: {
|
|
106
|
-
resolved: false,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
115
|
+
populate,
|
|
110
116
|
});
|
|
111
117
|
const total = await strapi.db.query((0, functions_2.getModelUid)("comment")).count({
|
|
112
118
|
where: params.where,
|
|
@@ -216,18 +222,30 @@ module.exports = ({ strapi }) => ({
|
|
|
216
222
|
},
|
|
217
223
|
},
|
|
218
224
|
};
|
|
219
|
-
const
|
|
225
|
+
const basePopulate = {
|
|
220
226
|
populate: {
|
|
221
|
-
authorUser: defaultAuthorUserPopulate,
|
|
222
227
|
threadOf: {
|
|
223
228
|
populate: {
|
|
224
|
-
authorUser: defaultAuthorUserPopulate,
|
|
225
229
|
...reportsPopulation,
|
|
226
230
|
},
|
|
227
231
|
},
|
|
228
232
|
...reportsPopulation,
|
|
229
233
|
},
|
|
230
234
|
};
|
|
235
|
+
const defaultPopulate = defaultAuthorUserPopulate
|
|
236
|
+
? {
|
|
237
|
+
populate: {
|
|
238
|
+
...basePopulate.populate,
|
|
239
|
+
authorUser: defaultAuthorUserPopulate,
|
|
240
|
+
threadOf: {
|
|
241
|
+
populate: {
|
|
242
|
+
...basePopulate.populate.threadOf.populate,
|
|
243
|
+
authorUser: defaultAuthorUserPopulate,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
}
|
|
248
|
+
: basePopulate;
|
|
231
249
|
const entity = await strapi.db
|
|
232
250
|
.query((0, functions_2.getModelUid)("comment"))
|
|
233
251
|
.findOne({
|
|
@@ -450,11 +468,12 @@ module.exports = ({ strapi }) => ({
|
|
|
450
468
|
data: {
|
|
451
469
|
approvalStatus: "APPROVED",
|
|
452
470
|
authorId: author.id,
|
|
453
|
-
authorName: author
|
|
471
|
+
authorName: (0, functions_2.getAuthorName)(author),
|
|
454
472
|
authorEmail: author.email,
|
|
455
473
|
content: body,
|
|
456
474
|
threadOf: threadId,
|
|
457
|
-
related: entity.related
|
|
475
|
+
related: entity.related,
|
|
476
|
+
isAdminComment: true,
|
|
458
477
|
},
|
|
459
478
|
});
|
|
460
479
|
},
|
|
@@ -143,6 +143,9 @@ module.exports = ({ strapi }) => ({
|
|
|
143
143
|
id,
|
|
144
144
|
related: relation,
|
|
145
145
|
});
|
|
146
|
+
if (reportAgainstEntity.isAdminComment) {
|
|
147
|
+
throw new error_1.default(403, `You're not allowed to take an action on that entity. This in a admin comment.`);
|
|
148
|
+
}
|
|
146
149
|
if (reportAgainstEntity) {
|
|
147
150
|
const entity = await strapi.db
|
|
148
151
|
.query((0, functions_2.getModelUid)("comment-report"))
|
|
@@ -173,7 +176,7 @@ module.exports = ({ strapi }) => ({
|
|
|
173
176
|
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.`);
|
|
174
177
|
}
|
|
175
178
|
catch (e) {
|
|
176
|
-
throw
|
|
179
|
+
throw e;
|
|
177
180
|
}
|
|
178
181
|
},
|
|
179
182
|
async markAsRemoved(id, relation, authorId, user) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Id, StrapiUser } from "strapi-typed";
|
|
1
|
+
import { Id, StrapiAdmin, StrapiUser } from "strapi-typed";
|
|
2
2
|
import { Comment, ToBeFixed } from "../../../types";
|
|
3
3
|
import PluginError from "./../../utils/error";
|
|
4
4
|
export declare const buildNestedStructure: (entities: Array<Comment>, id?: Id | null, field?: string, dropBlockedThreads?: boolean, blockNestedThreads?: boolean) => Array<Comment>;
|
|
@@ -10,4 +10,5 @@ export declare const convertContentTypeNameToSlug: (str: string) => string;
|
|
|
10
10
|
export declare const buildAuthorModel: (item: Comment, fieldsToPopulate?: Array<string>) => Comment;
|
|
11
11
|
export declare const buildConfigQueryProp: (prop?: undefined | string | Array<string>) => string;
|
|
12
12
|
export declare const resolveUserContextError: (user: StrapiUser) => PluginError;
|
|
13
|
+
export declare const getAuthorName: (author: StrapiAdmin) => any;
|
|
13
14
|
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveUserContextError = exports.buildConfigQueryProp = exports.buildAuthorModel = exports.convertContentTypeNameToSlug = exports.filterOurResolvedReports = exports.getModelUid = exports.getRelatedGroups = exports.isEqualEntity = exports.buildNestedStructure = void 0;
|
|
6
|
+
exports.getAuthorName = exports.resolveUserContextError = exports.buildConfigQueryProp = exports.buildAuthorModel = exports.convertContentTypeNameToSlug = exports.filterOurResolvedReports = exports.getModelUid = exports.getRelatedGroups = exports.isEqualEntity = exports.buildNestedStructure = void 0;
|
|
7
7
|
const error_1 = __importDefault(require("./../../utils/error"));
|
|
8
8
|
const constants_1 = require("./../../utils/constants");
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
@@ -105,4 +105,12 @@ const resolveUserContextError = (user) => {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
exports.resolveUserContextError = resolveUserContextError;
|
|
108
|
+
const getAuthorName = (author) => {
|
|
109
|
+
const { lastname, username, firstname } = author;
|
|
110
|
+
if (lastname)
|
|
111
|
+
return `${firstname} ${lastname}`;
|
|
112
|
+
else
|
|
113
|
+
return username || firstname;
|
|
114
|
+
};
|
|
115
|
+
exports.getAuthorName = getAuthorName;
|
|
108
116
|
//# sourceMappingURL=functions.js.map
|
package/server/utils/error.d.ts
CHANGED