strapi-plugin-comments 2.1.7 → 2.2.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/README.md +11 -2
- package/admin/src/components/Avatar/index.d.ts +3 -2
- package/admin/src/components/Avatar/index.js +2 -2
- package/admin/src/components/CommentReviewModal/index.d.ts +11 -0
- package/admin/src/components/CommentReviewModal/index.js +19 -0
- package/admin/src/components/ConfirmationDialog/index.d.ts +12 -10
- package/admin/src/components/ConfirmationDialog/index.js +3 -3
- package/admin/src/components/DiscussionStatus/index.d.ts +2 -1
- package/admin/src/components/DiscussionThread/index.d.ts +11 -5
- package/admin/src/components/DiscussionThread/index.js +3 -3
- package/admin/src/components/DiscussionThreadItem/index.d.ts +2 -7
- package/admin/src/components/DiscussionThreadItem/index.js +3 -12
- package/admin/src/components/DiscussionThreadItemActions/index.d.ts +10 -6
- package/admin/src/components/DiscussionThreadItemActions/index.js +75 -53
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.d.ts +9 -6
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +6 -9
- package/admin/src/components/DiscussionThreadItemFooter/index.d.ts +14 -7
- package/admin/src/components/DiscussionThreadItemFooter/index.js +3 -3
- package/admin/src/components/DiscussionThreadItemReviewAction/index.d.ts +14 -18
- package/admin/src/components/DiscussionThreadItemReviewAction/index.js +71 -52
- package/admin/src/components/FormSwitch/index.d.ts +2 -1
- package/admin/src/components/Hint/index.d.ts +14 -0
- package/admin/src/components/Hint/index.js +22 -0
- package/admin/src/components/LoadingIndicatorOverlay/index.d.ts +2 -1
- package/admin/src/components/ModeratorResponse/index.d.ts +8 -0
- package/admin/src/components/ModeratorResponse/index.js +108 -0
- package/admin/src/components/ModeratorResponse/styles.d.ts +2 -0
- package/admin/src/components/ModeratorResponse/styles.js +12 -0
- package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.d.ts +11 -0
- package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.js +98 -0
- package/admin/src/components/Nav/index.d.ts +2 -1
- package/admin/src/components/Nav/index.js +6 -9
- package/admin/src/components/PluginIcon/index.d.ts +2 -1
- package/admin/src/components/PluginIcon/index.js +2 -6
- package/admin/src/components/PreviewWysiwyg/Wrapper.d.ts +3 -0
- package/admin/src/components/PreviewWysiwyg/Wrapper.js +162 -0
- package/admin/src/components/PreviewWysiwyg/index.d.ts +7 -0
- package/admin/src/components/PreviewWysiwyg/index.js +39 -0
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.d.ts +3 -0
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.js +88 -0
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.d.ts +3 -0
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +18 -0
- package/admin/src/components/ReportsActions/components/BlockMenu/index.d.ts +16 -0
- package/admin/src/components/ReportsActions/components/BlockMenu/index.js +51 -0
- package/admin/src/components/ReportsActions/index.d.ts +12 -0
- package/admin/src/components/ReportsActions/index.js +31 -0
- package/admin/src/components/ReportsReviewModal/index.d.ts +14 -8
- package/admin/src/components/ReportsReviewTable/index.d.ts +13 -24
- package/admin/src/components/ReportsReviewTable/index.js +11 -24
- package/admin/src/components/StatusBadge/index.d.ts +2 -1
- package/admin/src/components/TableFilters/index.d.ts +12 -2
- package/admin/src/components/TableFilters/index.js +2 -2
- package/admin/src/components/TablePagination/index.d.ts +9 -2
- package/admin/src/components/Wysiwyg/Editor.d.ts +17 -0
- package/admin/src/components/Wysiwyg/Editor.js +84 -0
- package/admin/src/components/Wysiwyg/EditorLayout.d.ts +12 -0
- package/admin/src/components/Wysiwyg/EditorLayout.js +99 -0
- package/admin/src/components/Wysiwyg/EditorStylesContainer.d.ts +2 -0
- package/admin/src/components/Wysiwyg/EditorStylesContainer.js +348 -0
- package/admin/src/components/Wysiwyg/WysiwygFooter.d.ts +7 -0
- package/admin/src/components/Wysiwyg/WysiwygFooter.js +25 -0
- package/admin/src/components/Wysiwyg/WysiwygNav.d.ts +13 -0
- package/admin/src/components/Wysiwyg/WysiwygNav.js +118 -0
- package/admin/src/components/Wysiwyg/WysiwygStyles.d.ts +8 -0
- package/admin/src/components/Wysiwyg/WysiwygStyles.js +59 -0
- package/admin/src/components/Wysiwyg/index.d.ts +28 -0
- package/admin/src/components/Wysiwyg/index.js +136 -0
- package/admin/src/components/Wysiwyg/tests/index.test.d.ts +2 -0
- package/admin/src/components/Wysiwyg/tests/index.test.js +1633 -0
- package/admin/src/components/Wysiwyg/utils/continueList.d.ts +3 -0
- package/admin/src/components/Wysiwyg/utils/continueList.js +83 -0
- package/admin/src/components/Wysiwyg/utils/utils.d.ts +15 -0
- package/admin/src/components/Wysiwyg/utils/utils.js +249 -0
- package/admin/src/components/icons/comments.d.ts +2 -1
- package/admin/src/components/icons/index.d.ts +2 -5
- package/admin/src/components/icons/index.js +24 -12
- package/admin/src/components/icons/lock.d.ts +2 -1
- package/admin/src/components/icons/review.d.ts +2 -1
- package/admin/src/components/icons/strapiIcons.d.ts +24 -0
- package/admin/src/components/icons/strapiIcons.js +35 -0
- package/admin/src/components/icons/unlock.d.ts +2 -1
- package/admin/src/custom-fields/comments/components/icon.d.ts +3 -0
- package/admin/src/custom-fields/comments/components/icon.js +14 -0
- package/admin/src/custom-fields/comments/components/index.d.ts +3 -0
- package/admin/src/custom-fields/comments/components/index.js +19 -0
- package/admin/src/custom-fields/comments/components/input/index.d.ts +3 -0
- package/admin/src/custom-fields/comments/components/input/index.js +5 -0
- package/admin/src/custom-fields/comments/components/input/input.d.ts +4 -0
- package/admin/src/custom-fields/comments/components/input/input.js +102 -0
- package/admin/src/custom-fields/comments/components/input/types.d.ts +10 -0
- package/admin/src/custom-fields/comments/components/input/types.js +3 -0
- package/admin/src/custom-fields/comments/components/input/utils.d.ts +35 -0
- package/admin/src/custom-fields/comments/components/input/utils.js +146 -0
- package/admin/src/custom-fields/comments/index.d.ts +3 -0
- package/admin/src/custom-fields/comments/index.js +53 -0
- package/admin/src/custom-fields/index.d.ts +3 -0
- package/admin/src/custom-fields/index.js +13 -0
- package/admin/src/hooks/useConfig.d.ts +4 -4
- package/admin/src/hooks/useConfig.js +3 -6
- package/admin/src/hooks/useReportsActionsHandlers.d.ts +19 -0
- package/admin/src/hooks/useReportsActionsHandlers.js +70 -0
- package/admin/src/index.d.ts +2 -1
- package/admin/src/index.js +4 -2
- package/admin/src/pages/App/index.js +8 -7
- package/admin/src/pages/App/reducer/index.d.ts +1 -1
- package/admin/src/pages/ComingSoonPage/index.d.ts +2 -1
- package/admin/src/pages/ComingSoonPage/index.js +2 -2
- package/admin/src/pages/Details/components/DetailsEntity/index.d.ts +8 -6
- package/admin/src/pages/Details/components/DetailsFilters/index.d.ts +5 -3
- package/admin/src/pages/Details/index.js +10 -7
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.d.ts +11 -5
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +7 -81
- package/admin/src/pages/Discover/index.js +14 -13
- package/admin/src/pages/NoAccessPage/index.d.ts +4 -0
- package/admin/src/pages/NoAccessPage/index.js +31 -0
- package/admin/src/pages/Reports/components/ReportsTableRow/index.d.ts +16 -0
- package/admin/src/pages/Reports/components/ReportsTableRow/index.js +91 -0
- package/admin/src/pages/Reports/components/ReportsTableRow/styles.d.ts +2 -0
- package/admin/src/pages/Reports/components/ReportsTableRow/styles.js +14 -0
- package/admin/src/pages/Reports/index.d.ts +4 -0
- package/admin/src/pages/Reports/index.js +196 -0
- package/admin/src/pages/Reports/utils/api.d.ts +2 -0
- package/admin/src/pages/Reports/utils/api.js +16 -0
- package/admin/src/pages/Reports/utils/filtersSchema.d.ts +11 -0
- package/admin/src/pages/Reports/utils/filtersSchema.js +11 -0
- package/admin/src/pages/Settings/index.d.ts +2 -1
- package/admin/src/pages/Settings/index.js +6 -7
- package/admin/src/pages/utils/api.d.ts +17 -10
- package/admin/src/pages/utils/api.js +25 -2
- package/admin/src/reducers.d.ts +1 -1
- package/admin/src/translations/en.json +49 -1
- package/admin/src/utils/axiosInstance.d.ts +1 -1
- package/admin/src/utils/constants.d.ts +9 -5
- package/admin/src/utils/constants.js +5 -3
- package/admin/src/utils/errors.d.ts +5 -0
- package/admin/src/utils/errors.js +10 -0
- package/admin/src/utils/functions.d.ts +2 -0
- package/admin/src/utils/functions.js +11 -0
- package/admin/src/utils/getMessage.d.ts +1 -1
- package/admin/src/utils/getMessage.js +1 -1
- package/admin/src/utils/getRelatedGroups.d.ts +6 -2
- package/admin/src/utils/handleAPIError.d.ts +1 -1
- package/admin/src/utils/index.d.ts +16 -11
- package/admin/src/utils/index.js +12 -1
- package/admin/src/utils/renderInitials.js +6 -5
- package/admin/src/utils/resolveCommentStatus.d.ts +8 -2
- package/admin/src/utils/resolveReportStatus.d.ts +4 -0
- package/admin/src/utils/resolveReportStatus.js +23 -0
- package/admin/src/utils/resolveReportStatusColor.d.ts +4 -0
- package/admin/src/utils/resolveReportStatusColor.js +17 -0
- package/package.json +7 -4
- package/server/controllers/admin.js +67 -2
- package/server/index.d.ts +1 -1
- package/server/register/custom-fields/comments.d.ts +6 -0
- package/server/register/custom-fields/comments.js +9 -0
- package/server/register/custom-fields/index.d.ts +3 -0
- package/server/register/custom-fields/index.js +14 -0
- package/server/register/index.d.ts +4 -0
- package/server/register/index.js +8 -0
- package/server/routes/admin.js +56 -0
- package/server/services/admin.d.ts +1 -1
- package/server/services/admin.js +196 -10
- package/server/services/client.js +1 -1
- package/server/utils/error.js +1 -1
- package/strapi-server.d.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/types/utils.d.ts +5 -0
- package/types/utils.js +10 -0
- package/server/register.d.ts +0 -3
- package/server/register.js +0 -4
package/server/services/admin.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
const functions_1 = require("./../utils/functions");
|
|
6
6
|
const lodash_1 = require("lodash");
|
|
7
7
|
const error_1 = __importDefault(require("./../utils/error"));
|
|
8
|
+
const utils_1 = require("./../../types/utils");
|
|
8
9
|
const functions_2 = require("./utils/functions");
|
|
9
10
|
const constants_1 = require("./../utils/constants");
|
|
10
11
|
module.exports = ({ strapi }) => ({
|
|
@@ -125,11 +126,87 @@ module.exports = ({ strapi }) => ({
|
|
|
125
126
|
},
|
|
126
127
|
};
|
|
127
128
|
},
|
|
129
|
+
async findReports(query) {
|
|
130
|
+
const { _q, filters, orderBy, page = 1, pageSize = 10, } = (0, functions_1.parseParams)(query);
|
|
131
|
+
const defaultWhere = {
|
|
132
|
+
resolved: { $notNull: true },
|
|
133
|
+
};
|
|
134
|
+
const defaultAuthorUserPopulate = this.getDefaultAuthorPopulate();
|
|
135
|
+
let params = {
|
|
136
|
+
where: !(0, lodash_1.isEmpty)(filters)
|
|
137
|
+
? {
|
|
138
|
+
...defaultWhere,
|
|
139
|
+
...filters,
|
|
140
|
+
}
|
|
141
|
+
: { ...defaultWhere },
|
|
142
|
+
offset: (page - 1) * pageSize,
|
|
143
|
+
limit: pageSize,
|
|
144
|
+
orderBy: orderBy || [{ resolved: "asc" }, { createdAt: "desc" }],
|
|
145
|
+
};
|
|
146
|
+
if (_q) {
|
|
147
|
+
params = {
|
|
148
|
+
...params,
|
|
149
|
+
where: {
|
|
150
|
+
...params.where,
|
|
151
|
+
content: {
|
|
152
|
+
$contains: _q,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const entities = await strapi.db
|
|
158
|
+
.query((0, functions_2.getModelUid)("comment-report"))
|
|
159
|
+
.findMany({
|
|
160
|
+
...params,
|
|
161
|
+
populate: ["related"],
|
|
162
|
+
});
|
|
163
|
+
const total = await strapi.db
|
|
164
|
+
.query((0, functions_2.getModelUid)("comment-report"))
|
|
165
|
+
.count({
|
|
166
|
+
where: params.where,
|
|
167
|
+
});
|
|
168
|
+
const reportedCommentsIds = entities.map((report) => report.related.id);
|
|
169
|
+
const commentsInThreads = await strapi.db
|
|
170
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
171
|
+
.findMany({
|
|
172
|
+
where: {
|
|
173
|
+
threadOf: reportedCommentsIds,
|
|
174
|
+
},
|
|
175
|
+
populate: ["threadOf"],
|
|
176
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
177
|
+
});
|
|
178
|
+
const commentWithThreadIds = [
|
|
179
|
+
...new Set(commentsInThreads.map(({ threadOf }) => {
|
|
180
|
+
(0, utils_1.assertComment)(threadOf);
|
|
181
|
+
return threadOf.id;
|
|
182
|
+
})),
|
|
183
|
+
];
|
|
184
|
+
const result = entities.map((_) => {
|
|
185
|
+
const isCommentWithThread = commentWithThreadIds.includes(_.related.id);
|
|
186
|
+
return (0, functions_2.filterOurResolvedReports)(this.getCommonService().sanitizeCommentEntity({
|
|
187
|
+
..._,
|
|
188
|
+
related: this.getCommonService().sanitizeCommentEntity({
|
|
189
|
+
..._.related,
|
|
190
|
+
gotThread: isCommentWithThread,
|
|
191
|
+
}),
|
|
192
|
+
}, defaultAuthorUserPopulate?.populate));
|
|
193
|
+
});
|
|
194
|
+
const pageCount = Math.floor(total / pageSize);
|
|
195
|
+
return {
|
|
196
|
+
result,
|
|
197
|
+
pagination: {
|
|
198
|
+
page: page,
|
|
199
|
+
pageSize: pageSize,
|
|
200
|
+
pageCount: total % pageSize === 0 ? pageCount : pageCount + 1,
|
|
201
|
+
total,
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
},
|
|
128
205
|
async findOneAndThread(id, { removed, ...query }) {
|
|
129
206
|
const defaultAuthorUserPopulate = this.getDefaultAuthorPopulate();
|
|
130
207
|
const defaultWhere = !removed
|
|
131
208
|
? {
|
|
132
|
-
$or: [{ removed: false }, { removed:
|
|
209
|
+
$or: [{ removed: false }, { removed: { $notNull: false } }],
|
|
133
210
|
}
|
|
134
211
|
: {};
|
|
135
212
|
const reportsPopulation = {
|
|
@@ -213,6 +290,17 @@ module.exports = ({ strapi }) => ({
|
|
|
213
290
|
});
|
|
214
291
|
return this.getCommonService().sanitizeCommentEntity(changedEntity);
|
|
215
292
|
},
|
|
293
|
+
async deleteComment(id) {
|
|
294
|
+
const changedEntity = await strapi.db
|
|
295
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
296
|
+
.update({
|
|
297
|
+
where: { id },
|
|
298
|
+
data: {
|
|
299
|
+
removed: true,
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
return this.getCommonService().sanitizeCommentEntity(changedEntity);
|
|
303
|
+
},
|
|
216
304
|
async blockCommentThread(id, forceStatus) {
|
|
217
305
|
const existingEntity = await this.getCommonService().findOne({ id });
|
|
218
306
|
const status = !(0, lodash_1.isNil)(forceStatus)
|
|
@@ -262,7 +350,7 @@ module.exports = ({ strapi }) => ({
|
|
|
262
350
|
data: { resolved: true },
|
|
263
351
|
});
|
|
264
352
|
},
|
|
265
|
-
async
|
|
353
|
+
async resolveCommentMultipleAbuseReports(ids, commentId) {
|
|
266
354
|
const reportsToResolve = await strapi.db
|
|
267
355
|
.query((0, functions_2.getModelUid)("comment-report"))
|
|
268
356
|
.findMany({
|
|
@@ -270,7 +358,7 @@ module.exports = ({ strapi }) => ({
|
|
|
270
358
|
id: ids,
|
|
271
359
|
related: commentId,
|
|
272
360
|
},
|
|
273
|
-
populate: [
|
|
361
|
+
populate: ["related"],
|
|
274
362
|
});
|
|
275
363
|
if (reportsToResolve.length === ids.length) {
|
|
276
364
|
return strapi.db
|
|
@@ -280,20 +368,118 @@ module.exports = ({ strapi }) => ({
|
|
|
280
368
|
data: { resolved: true },
|
|
281
369
|
});
|
|
282
370
|
}
|
|
283
|
-
throw new error_1.default(400,
|
|
371
|
+
throw new error_1.default(400, "At least one of selected reports got invalid comment entity relation. Try again.");
|
|
372
|
+
},
|
|
373
|
+
async resolveAllAbuseReportsForComment(commentId) {
|
|
374
|
+
if (commentId) {
|
|
375
|
+
const blockedCommentReports = strapi.db
|
|
376
|
+
.query((0, functions_2.getModelUid)("comment-report"))
|
|
377
|
+
.findMany({
|
|
378
|
+
where: {
|
|
379
|
+
related: commentId,
|
|
380
|
+
resolved: false,
|
|
381
|
+
},
|
|
382
|
+
populate: ["related"],
|
|
383
|
+
});
|
|
384
|
+
const reportIds = (await blockedCommentReports).map((report) => report.id);
|
|
385
|
+
return strapi.db
|
|
386
|
+
.query((0, functions_2.getModelUid)("comment-report"))
|
|
387
|
+
.updateMany({
|
|
388
|
+
where: {
|
|
389
|
+
id: reportIds,
|
|
390
|
+
},
|
|
391
|
+
data: { resolved: true },
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
throw new error_1.default(400, "There is something wrong with comment Id. Try again.");
|
|
395
|
+
},
|
|
396
|
+
async resolveAllAbuseReportsForThread(commentId) {
|
|
397
|
+
if (commentId) {
|
|
398
|
+
const commentsInThread = strapi.db
|
|
399
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
400
|
+
.findMany({
|
|
401
|
+
where: {
|
|
402
|
+
threadOf: commentId,
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
const commentsInThreadIds = (await commentsInThread).map((comment) => comment.id);
|
|
406
|
+
commentsInThreadIds.push(commentId);
|
|
407
|
+
const reportsInThread = strapi.db
|
|
408
|
+
.query((0, functions_2.getModelUid)("comment-report"))
|
|
409
|
+
.findMany({
|
|
410
|
+
where: {
|
|
411
|
+
related: commentsInThreadIds,
|
|
412
|
+
resolved: false,
|
|
413
|
+
},
|
|
414
|
+
populate: ["related"],
|
|
415
|
+
});
|
|
416
|
+
const reportsInThreadIds = (await reportsInThread).map((report) => report.id);
|
|
417
|
+
return strapi.db
|
|
418
|
+
.query((0, functions_2.getModelUid)("comment-report"))
|
|
419
|
+
.updateMany({
|
|
420
|
+
where: {
|
|
421
|
+
id: reportsInThreadIds,
|
|
422
|
+
},
|
|
423
|
+
data: { resolved: true },
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
throw new error_1.default(400, "There is something wrong with comment Id. Try again.");
|
|
427
|
+
},
|
|
428
|
+
async resolveMultipleAbuseReports(ids) {
|
|
429
|
+
if (!!ids.length) {
|
|
430
|
+
return strapi.db
|
|
431
|
+
.query((0, functions_2.getModelUid)("comment-report"))
|
|
432
|
+
.updateMany({
|
|
433
|
+
where: { id: { $in: ids } },
|
|
434
|
+
data: { resolved: true },
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
throw new error_1.default(400, "At least one of selected reports got invalid comment entity relation. Try again.");
|
|
438
|
+
},
|
|
439
|
+
async postComment(threadId, body, author) {
|
|
440
|
+
const entity = await strapi.db
|
|
441
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
442
|
+
.findOne({
|
|
443
|
+
where: {
|
|
444
|
+
id: threadId,
|
|
445
|
+
},
|
|
446
|
+
});
|
|
447
|
+
return await strapi.db
|
|
448
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
449
|
+
.create({
|
|
450
|
+
data: {
|
|
451
|
+
approvalStatus: "APPROVED",
|
|
452
|
+
authorId: author.id,
|
|
453
|
+
authorName: author.username,
|
|
454
|
+
authorEmail: author.email,
|
|
455
|
+
content: body,
|
|
456
|
+
threadOf: threadId,
|
|
457
|
+
related: entity.related
|
|
458
|
+
},
|
|
459
|
+
});
|
|
460
|
+
},
|
|
461
|
+
async updateComment(id, body) {
|
|
462
|
+
const updateComment = await strapi.db
|
|
463
|
+
.query((0, functions_2.getModelUid)("comment"))
|
|
464
|
+
.update({
|
|
465
|
+
where: { id },
|
|
466
|
+
data: {
|
|
467
|
+
content: body
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
return this.getCommonService().sanitizeCommentEntity(updateComment);
|
|
284
471
|
},
|
|
285
472
|
getDefaultAuthorPopulate() {
|
|
286
|
-
const strapiUserTypeUid =
|
|
287
|
-
const allowedTypes = [
|
|
473
|
+
const strapiUserTypeUid = "plugin::users-permissions.user";
|
|
474
|
+
const allowedTypes = ["media", "relation"];
|
|
288
475
|
const { attributes } = strapi.contentTypes[strapiUserTypeUid] || {};
|
|
289
|
-
const relationTypes = Object.keys(attributes)
|
|
290
|
-
|
|
291
|
-
if (relationTypes.includes('avatar')) {
|
|
476
|
+
const relationTypes = Object.keys(attributes)?.filter((key) => allowedTypes.includes(attributes[key]?.type));
|
|
477
|
+
if (relationTypes.includes("avatar")) {
|
|
292
478
|
return {
|
|
293
479
|
populate: { avatar: true },
|
|
294
480
|
};
|
|
295
481
|
}
|
|
296
482
|
return undefined;
|
|
297
|
-
}
|
|
483
|
+
},
|
|
298
484
|
});
|
|
299
485
|
//# sourceMappingURL=admin.js.map
|
|
@@ -24,7 +24,7 @@ module.exports = ({ strapi }) => ({
|
|
|
24
24
|
}
|
|
25
25
|
const relatedEntity = await strapi.db
|
|
26
26
|
.query(uid)
|
|
27
|
-
.findOne(relatedId);
|
|
27
|
+
.findOne({ where: { id: relatedId } });
|
|
28
28
|
if (!relatedEntity) {
|
|
29
29
|
throw new error_1.default(400, `Relation for field "related" does not exist. Check your payload please.`);
|
|
30
30
|
}
|
package/server/utils/error.js
CHANGED
package/strapi-server.d.ts
CHANGED
|
@@ -154,7 +154,7 @@ declare const _default: () => {
|
|
|
154
154
|
};
|
|
155
155
|
validator: (config: CommentsPluginConfig) => void;
|
|
156
156
|
};
|
|
157
|
-
register: () => void;
|
|
157
|
+
register: (context: import("strapi-typed").StrapiContext) => void;
|
|
158
158
|
bootstrap: ({ strapi }: import("strapi-typed").StrapiContext) => Promise<void>;
|
|
159
159
|
destroy: () => void;
|
|
160
160
|
controllers: {
|