strapi-plugin-comments 3.0.4 → 3.0.6

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 CHANGED
@@ -104,7 +104,7 @@ In our minimum support we're following [official Node.js releases timelines](htt
104
104
 
105
105
  **Supported Strapi versions**:
106
106
 
107
- - Strapi v5.7.0 (recently tested)
107
+ - Strapi v5.8.1 (recently tested)
108
108
  - Strapi v5.x
109
109
 
110
110
  > This plugin is designed for **Strapi v5**. To get support for other Strapi versions, please follow the [versions](#-versions) section.
@@ -8185,6 +8185,19 @@ const bootstrap = async ({ strapi: strapi2 }) => {
8185
8185
  }
8186
8186
  ];
8187
8187
  await strapi2.admin.services.permission.actionProvider.registerMany(actions);
8188
+ const commonService2 = getPluginService(strapi2, "common");
8189
+ const enabledCollections = await commonService2.getConfig(CONFIG_PARAMS.ENABLED_COLLECTIONS, []);
8190
+ if (enabledCollections.length) {
8191
+ strapi2.db.lifecycles.subscribe({
8192
+ models: enabledCollections,
8193
+ afterDelete: async (event) => {
8194
+ const uid = event.model.uid;
8195
+ const { documentId, locale } = event.result;
8196
+ const relation = [uid, documentId].join(":");
8197
+ await commonService2.perRemove(relation, locale);
8198
+ }
8199
+ });
8200
+ }
8188
8201
  };
8189
8202
  const defaultPluginConfig = {
8190
8203
  isValidationEnabled: true,
@@ -8886,6 +8899,9 @@ const getCommentRepositorySource = (strapi2) => {
8886
8899
  const isValidationEnabled = await getConfig(strapi2, "isValidationEnabled", false);
8887
8900
  return strapi2.query(modelUid).delete(params).then((result) => result ? shouldValidateObject(isValidationEnabled, commentResultValidator.findOne)(result) : null);
8888
8901
  },
8902
+ async deleteMany(params) {
8903
+ return strapi2.query(modelUid).deleteMany(params);
8904
+ },
8889
8905
  updateMany(params) {
8890
8906
  return strapi2.query(modelUid).updateMany(params);
8891
8907
  },
@@ -9992,7 +10008,7 @@ const clientService = ({ strapi: strapi2 }) => {
9992
10008
  );
9993
10009
  const threadData = await tryCatch(
9994
10010
  async () => {
9995
- return threadOf ? await this.getCommonService().findOne({ id: threadOf, related: relation, locale }) : null;
10011
+ return threadOf ? await this.getCommonService().findOne({ id: threadOf, related: relation, locale: locale || null }) : null;
9996
10012
  },
9997
10013
  new PluginError2(400, "Thread does not exist")
9998
10014
  );
@@ -10509,6 +10525,15 @@ const commonService = ({ strapi: strapi2 }) => ({
10509
10525
  }
10510
10526
  return content;
10511
10527
  },
10528
+ async perRemove(related, locale) {
10529
+ const defaultLocale = await strapi2.plugin("i18n")?.service("locales").getDefaultLocale() || null;
10530
+ return getCommentRepository(strapi2).deleteMany({
10531
+ where: {
10532
+ related,
10533
+ $or: [{ locale }, defaultLocale === locale ? { locale: { $eq: null } } : null].filter(Boolean)
10534
+ }
10535
+ });
10536
+ },
10512
10537
  registerLifecycleHook() {
10513
10538
  },
10514
10539
  async runLifecycleHook() {
@@ -8184,6 +8184,19 @@ const bootstrap = async ({ strapi: strapi2 }) => {
8184
8184
  }
8185
8185
  ];
8186
8186
  await strapi2.admin.services.permission.actionProvider.registerMany(actions);
8187
+ const commonService2 = getPluginService(strapi2, "common");
8188
+ const enabledCollections = await commonService2.getConfig(CONFIG_PARAMS.ENABLED_COLLECTIONS, []);
8189
+ if (enabledCollections.length) {
8190
+ strapi2.db.lifecycles.subscribe({
8191
+ models: enabledCollections,
8192
+ afterDelete: async (event) => {
8193
+ const uid = event.model.uid;
8194
+ const { documentId, locale } = event.result;
8195
+ const relation = [uid, documentId].join(":");
8196
+ await commonService2.perRemove(relation, locale);
8197
+ }
8198
+ });
8199
+ }
8187
8200
  };
8188
8201
  const defaultPluginConfig = {
8189
8202
  isValidationEnabled: true,
@@ -8885,6 +8898,9 @@ const getCommentRepositorySource = (strapi2) => {
8885
8898
  const isValidationEnabled = await getConfig(strapi2, "isValidationEnabled", false);
8886
8899
  return strapi2.query(modelUid).delete(params).then((result) => result ? shouldValidateObject(isValidationEnabled, commentResultValidator.findOne)(result) : null);
8887
8900
  },
8901
+ async deleteMany(params) {
8902
+ return strapi2.query(modelUid).deleteMany(params);
8903
+ },
8888
8904
  updateMany(params) {
8889
8905
  return strapi2.query(modelUid).updateMany(params);
8890
8906
  },
@@ -9991,7 +10007,7 @@ const clientService = ({ strapi: strapi2 }) => {
9991
10007
  );
9992
10008
  const threadData = await tryCatch(
9993
10009
  async () => {
9994
- return threadOf ? await this.getCommonService().findOne({ id: threadOf, related: relation, locale }) : null;
10010
+ return threadOf ? await this.getCommonService().findOne({ id: threadOf, related: relation, locale: locale || null }) : null;
9995
10011
  },
9996
10012
  new PluginError2(400, "Thread does not exist")
9997
10013
  );
@@ -10508,6 +10524,15 @@ const commonService = ({ strapi: strapi2 }) => ({
10508
10524
  }
10509
10525
  return content;
10510
10526
  },
10527
+ async perRemove(related, locale) {
10528
+ const defaultLocale = await strapi2.plugin("i18n")?.service("locales").getDefaultLocale() || null;
10529
+ return getCommentRepository(strapi2).deleteMany({
10530
+ where: {
10531
+ related,
10532
+ $or: [{ locale }, defaultLocale === locale ? { locale: { $eq: null } } : null].filter(Boolean)
10533
+ }
10534
+ });
10535
+ },
10511
10536
  registerLifecycleHook() {
10512
10537
  },
10513
10538
  async runLifecycleHook() {
@@ -4369,7 +4369,7 @@ declare const _default: {
4369
4369
  total?: number;
4370
4370
  };
4371
4371
  }>;
4372
- findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit }: {
4372
+ findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit, }: {
4373
4373
  sort?: string;
4374
4374
  locale?: string;
4375
4375
  relation?: `${string}::${string}.${string}`;
@@ -5969,6 +5969,7 @@ declare const _default: {
5969
5969
  };
5970
5970
  }[T_5], deepLimit?: number): Promise<boolean>;
5971
5971
  checkBadWords(content: string): Promise<string>;
5972
+ perRemove(related: string, locale?: string): Promise<import("@strapi/database/dist/types").CountResult>;
5972
5973
  registerLifecycleHook(): void;
5973
5974
  runLifecycleHook(): Promise<void>;
5974
5975
  };
@@ -7706,7 +7707,7 @@ declare const _default: {
7706
7707
  total?: number;
7707
7708
  };
7708
7709
  }>;
7709
- findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit }: {
7710
+ findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit, }: {
7710
7711
  sort?: string;
7711
7712
  locale?: string;
7712
7713
  relation?: `${string}::${string}.${string}`;
@@ -9306,6 +9307,7 @@ declare const _default: {
9306
9307
  };
9307
9308
  }[T_5], deepLimit?: number): Promise<boolean>;
9308
9309
  checkBadWords(content: string): Promise<string>;
9310
+ perRemove(related: string, locale?: string): Promise<import("@strapi/database/dist/types").CountResult>;
9309
9311
  registerLifecycleHook(): void;
9310
9312
  runLifecycleHook(): Promise<void>;
9311
9313
  };
@@ -10551,7 +10553,7 @@ declare const _default: {
10551
10553
  total?: number;
10552
10554
  };
10553
10555
  }>;
10554
- findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit }: {
10556
+ findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit, }: {
10555
10557
  sort?: string;
10556
10558
  locale?: string;
10557
10559
  relation?: `${string}::${string}.${string}`;
@@ -12151,6 +12153,7 @@ declare const _default: {
12151
12153
  };
12152
12154
  }[T_5], deepLimit?: number): Promise<boolean>;
12153
12155
  checkBadWords(content: string): Promise<string>;
12156
+ perRemove(related: string, locale?: string): Promise<import("@strapi/database/dist/types").CountResult>;
12154
12157
  registerLifecycleHook(): void;
12155
12158
  runLifecycleHook(): Promise<void>;
12156
12159
  };
@@ -7,6 +7,7 @@ export declare const getCommentRepositorySource: (strapi: CoreStrapi) => {
7
7
  findOne(params: FindOneParams): Promise<CommentResultValidator['findOne'] | null>;
8
8
  update(params: Params): Promise<CommentResultValidator['findOne']>;
9
9
  delete(params: Params): Promise<CommentResultValidator['findOne'] | null>;
10
+ deleteMany(params: Params): Promise<import("@strapi/database/dist/types").CountResult>;
10
11
  updateMany(params: Params): Promise<import("@strapi/database/dist/types").CountResult>;
11
12
  create(params: Pick<Params, 'data' | 'populate'>): Promise<CommentResultValidator['create']>;
12
13
  };
@@ -16,6 +17,7 @@ export declare const getCommentRepository: (strapi: CoreStrapi) => {
16
17
  findOne(params: FindOneParams): Promise<CommentResultValidator['findOne'] | null>;
17
18
  update(params: Params): Promise<CommentResultValidator['findOne']>;
18
19
  delete(params: Params): Promise<CommentResultValidator['findOne'] | null>;
20
+ deleteMany(params: Params): Promise<import("@strapi/database/dist/types").CountResult>;
19
21
  updateMany(params: Params): Promise<import("@strapi/database/dist/types").CountResult>;
20
22
  create(params: Pick<Params, 'data' | 'populate'>): Promise<CommentResultValidator['create']>;
21
23
  };
@@ -818,7 +818,7 @@ declare const _default: ({ strapi }: StrapiContext) => {
818
818
  total?: number;
819
819
  };
820
820
  }>;
821
- findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit }: {
821
+ findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit, }: {
822
822
  sort?: string;
823
823
  locale?: string;
824
824
  relation?: `${string}::${string}.${string}`;
@@ -2418,6 +2418,7 @@ declare const _default: ({ strapi }: StrapiContext) => {
2418
2418
  };
2419
2419
  }[T_2], deepLimit?: number): Promise<boolean>;
2420
2420
  checkBadWords(content: string): Promise<string>;
2421
+ perRemove(related: string, locale?: string): Promise<import("@strapi/database/dist/types").CountResult>;
2421
2422
  registerLifecycleHook(): void;
2422
2423
  runLifecycleHook(): Promise<void>;
2423
2424
  };
@@ -822,7 +822,7 @@ export declare const clientService: ({ strapi }: StrapiContext) => {
822
822
  total?: number;
823
823
  };
824
824
  }>;
825
- findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit }: {
825
+ findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit, }: {
826
826
  sort?: string;
827
827
  locale?: string;
828
828
  relation?: `${string}::${string}.${string}`;
@@ -2422,6 +2422,7 @@ export declare const clientService: ({ strapi }: StrapiContext) => {
2422
2422
  };
2423
2423
  }[T_2], deepLimit?: number): Promise<boolean>;
2424
2424
  checkBadWords(content: string): Promise<string>;
2425
+ perRemove(related: string, locale?: string): Promise<import("@strapi/database/dist/types").CountResult>;
2425
2426
  registerLifecycleHook(): void;
2426
2427
  runLifecycleHook(): Promise<void>;
2427
2428
  };
@@ -20,7 +20,7 @@ declare const commonService: ({ strapi }: StrapiContext) => {
20
20
  data: Array<CommentWithRelated | Comment>;
21
21
  pagination?: Pagination;
22
22
  }>;
23
- findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit }: clientValidator.FindAllInHierarchyValidatorSchema, relatedEntity?: any): Promise<{
23
+ findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit, }: clientValidator.FindAllInHierarchyValidatorSchema, relatedEntity?: any): Promise<{
24
24
  id?: number;
25
25
  documentId?: string;
26
26
  content?: string;
@@ -561,6 +561,7 @@ declare const commonService: ({ strapi }: StrapiContext) => {
561
561
  };
562
562
  }[T_2], deepLimit?: number): Promise<boolean>;
563
563
  checkBadWords(content: string): Promise<string>;
564
+ perRemove(related: string, locale?: string): Promise<import("@strapi/database/dist/types").CountResult>;
564
565
  registerLifecycleHook(): void;
565
566
  runLifecycleHook(): Promise<void>;
566
567
  };
@@ -817,7 +817,7 @@ declare const pluginServices: {
817
817
  total?: number;
818
818
  };
819
819
  }>;
820
- findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit }: {
820
+ findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit, }: {
821
821
  sort?: string;
822
822
  locale?: string;
823
823
  relation?: `${string}::${string}.${string}`;
@@ -2417,6 +2417,7 @@ declare const pluginServices: {
2417
2417
  };
2418
2418
  }[T_2], deepLimit?: number): Promise<boolean>;
2419
2419
  checkBadWords(content: string): Promise<string>;
2420
+ perRemove(related: string, locale?: string): Promise<import("@strapi/database/dist/types").CountResult>;
2420
2421
  registerLifecycleHook(): void;
2421
2422
  runLifecycleHook(): Promise<void>;
2422
2423
  };
@@ -4154,7 +4155,7 @@ declare const pluginServices: {
4154
4155
  total?: number;
4155
4156
  };
4156
4157
  }>;
4157
- findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit }: {
4158
+ findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit, }: {
4158
4159
  sort?: string;
4159
4160
  locale?: string;
4160
4161
  relation?: `${string}::${string}.${string}`;
@@ -5754,6 +5755,7 @@ declare const pluginServices: {
5754
5755
  };
5755
5756
  }[T_2], deepLimit?: number): Promise<boolean>;
5756
5757
  checkBadWords(content: string): Promise<string>;
5758
+ perRemove(related: string, locale?: string): Promise<import("@strapi/database/dist/types").CountResult>;
5757
5759
  registerLifecycleHook(): void;
5758
5760
  runLifecycleHook(): Promise<void>;
5759
5761
  };
@@ -6999,7 +7001,7 @@ declare const pluginServices: {
6999
7001
  total?: number;
7000
7002
  };
7001
7003
  }>;
7002
- findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit }: {
7004
+ findAllInHierarchy({ filters, populate, sort, fields, startingFromId, dropBlockedThreads, isAdmin, omit, locale, limit, }: {
7003
7005
  sort?: string;
7004
7006
  locale?: string;
7005
7007
  relation?: `${string}::${string}.${string}`;
@@ -8599,6 +8601,7 @@ declare const pluginServices: {
8599
8601
  };
8600
8602
  }[T_2], deepLimit?: number): Promise<boolean>;
8601
8603
  checkBadWords(content: string): Promise<string>;
8604
+ perRemove(related: string, locale?: string): Promise<import("@strapi/database/dist/types").CountResult>;
8602
8605
  registerLifecycleHook(): void;
8603
8606
  runLifecycleHook(): Promise<void>;
8604
8607
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-comments",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "Strapi - Comments plugin",
5
5
  "strapi": {
6
6
  "name": "comments",
@@ -57,7 +57,7 @@
57
57
  "no-profanity": "^1.5.1",
58
58
  "react": "^18.3.1",
59
59
  "react-dom": "^18.3.1",
60
- "react-router-dom": "^6.26.2",
60
+ "react-router-dom": "^6.22.3",
61
61
  "sanitize-html": "^2.13.1",
62
62
  "styled-components": "^6.1.13",
63
63
  "zod": "^3.23.8",
@@ -66,12 +66,12 @@
66
66
  "devDependencies": {
67
67
  "@jest/types": "29.5.x",
68
68
  "@sensinum/strapi-utils": "^1.0.4",
69
- "@strapi/plugin-cloud": "^5.7.0",
70
- "@strapi/plugin-graphql": "5.7.0",
71
- "@strapi/plugin-users-permissions": "^5.7.0",
72
- "@strapi/sdk-plugin": "^5.2.8",
73
- "@strapi/strapi": "^5.7.0",
74
- "@strapi/types": "^5.7.0",
69
+ "@strapi/plugin-cloud": "^5.8.1",
70
+ "@strapi/plugin-graphql": "5.8.1",
71
+ "@strapi/plugin-users-permissions": "^5.8.1",
72
+ "@strapi/sdk-plugin": "^5.3.0",
73
+ "@strapi/strapi": "^5.8.1",
74
+ "@strapi/types": "^5.8.1",
75
75
  "@types/jest": "^29.5.12",
76
76
  "@types/koa": "^2.15.0",
77
77
  "@types/react": "^18.3.8",
@@ -88,11 +88,11 @@
88
88
  "typescript": "^5.6.2"
89
89
  },
90
90
  "peerDependencies": {
91
- "@strapi/sdk-plugin": "^5.2.8",
92
- "@strapi/strapi": "^5.7.0",
91
+ "@strapi/sdk-plugin": "^5.3.0",
92
+ "@strapi/strapi": "^5.8.1",
93
93
  "react": "^18.3.1",
94
94
  "react-dom": "^18.3.1",
95
- "react-router-dom": "^6.26.2",
95
+ "react-router-dom": "^6.22.3",
96
96
  "styled-components": "^6.1.13"
97
97
  },
98
98
  "nodemonConfig": {