strapi-plugin-comments 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51206,7 +51206,7 @@ const index = {
51206
51206
  id: `${pluginId}.plugin.name`,
51207
51207
  defaultMessage: displayName
51208
51208
  },
51209
- Component: () => Promise.resolve().then(() => require("./index-DCKroyap.js")),
51209
+ Component: () => Promise.resolve().then(() => require("./index-DidQUJKN.js")),
51210
51210
  permissions: pluginPermissions.access
51211
51211
  });
51212
51212
  app.createSettingSection(
@@ -51225,7 +51225,7 @@ const index = {
51225
51225
  },
51226
51226
  id: "comments",
51227
51227
  to: `/settings/${pluginId}`,
51228
- Component: () => Promise.resolve().then(() => require("./index-BMAhFLKR.js")),
51228
+ Component: () => Promise.resolve().then(() => require("./index-BTWJ00Fw.js")),
51229
51229
  permissions: pluginPermissions.settings
51230
51230
  }
51231
51231
  ]
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
- const index$2 = require("./index-DHhRVslt.js");
4
+ const index$2 = require("./index-BAXZ3d__.js");
5
5
  const admin = require("@strapi/strapi/admin");
6
6
  const reactQuery = require("@tanstack/react-query");
7
- const index$1 = require("./index-_4jTpBrc.js");
7
+ const index$1 = require("./index-CJVLjLWX.js");
8
8
  const React = require("react");
9
9
  const styled = require("styled-components");
10
10
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
- const index = require("./index-DHhRVslt.js");
3
+ const index = require("./index-BAXZ3d__.js");
4
4
  const reactQuery = require("@tanstack/react-query");
5
5
  const React = require("react");
6
6
  const admin = require("@strapi/strapi/admin");
@@ -3849,10 +3849,10 @@ lodash.exports;
3849
3849
  return result2;
3850
3850
  };
3851
3851
  }
3852
- var bind2 = baseRest(function(func, thisArg, partials) {
3852
+ var bind3 = baseRest(function(func, thisArg, partials) {
3853
3853
  var bitmask = WRAP_BIND_FLAG;
3854
3854
  if (partials.length) {
3855
- var holders = replaceHolders(partials, getHolder(bind2));
3855
+ var holders = replaceHolders(partials, getHolder(bind3));
3856
3856
  bitmask |= WRAP_PARTIAL_FLAG;
3857
3857
  }
3858
3858
  return createWrap(func, bitmask, thisArg, partials, holders);
@@ -4859,7 +4859,7 @@ lodash.exports;
4859
4859
  var bindAll = flatRest(function(object, methodNames) {
4860
4860
  arrayEach(methodNames, function(key) {
4861
4861
  key = toKey(key);
4862
- baseAssignValue(object, key, bind2(object[key], object));
4862
+ baseAssignValue(object, key, bind3(object[key], object));
4863
4863
  });
4864
4864
  return object;
4865
4865
  });
@@ -5056,7 +5056,7 @@ lodash.exports;
5056
5056
  lodash2.assignWith = assignWith;
5057
5057
  lodash2.at = at;
5058
5058
  lodash2.before = before;
5059
- lodash2.bind = bind2;
5059
+ lodash2.bind = bind3;
5060
5060
  lodash2.bindAll = bindAll;
5061
5061
  lodash2.bindKey = bindKey;
5062
5062
  lodash2.castArray = castArray;
@@ -5773,7 +5773,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
5773
5773
  var ys = arrObjKeys(obj, inspect2);
5774
5774
  var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
5775
5775
  var protoTag = obj instanceof Object ? "" : "null prototype";
5776
- var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
5776
+ var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
5777
5777
  var constructorTag = isPlainObject || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
5778
5778
  var tag = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat$1.call([], stringTag || [], protoTag || []), ": ") + "] " : "");
5779
5779
  if (ys.length === 0) {
@@ -5795,25 +5795,25 @@ function quote(s) {
5795
5795
  return $replace$1.call(String(s), /"/g, """);
5796
5796
  }
5797
5797
  function isArray$3(obj) {
5798
- return toStr(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5798
+ return toStr$1(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5799
5799
  }
5800
5800
  function isDate(obj) {
5801
- return toStr(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5801
+ return toStr$1(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5802
5802
  }
5803
5803
  function isRegExp$1(obj) {
5804
- return toStr(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5804
+ return toStr$1(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5805
5805
  }
5806
5806
  function isError(obj) {
5807
- return toStr(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5807
+ return toStr$1(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5808
5808
  }
5809
5809
  function isString(obj) {
5810
- return toStr(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5810
+ return toStr$1(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5811
5811
  }
5812
5812
  function isNumber(obj) {
5813
- return toStr(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5813
+ return toStr$1(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5814
5814
  }
5815
5815
  function isBoolean(obj) {
5816
- return toStr(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5816
+ return toStr$1(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5817
5817
  }
5818
5818
  function isSymbol(obj) {
5819
5819
  if (hasShammedSymbols) {
@@ -5849,7 +5849,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
5849
5849
  function has$3(obj, key) {
5850
5850
  return hasOwn$1.call(obj, key);
5851
5851
  }
5852
- function toStr(obj) {
5852
+ function toStr$1(obj) {
5853
5853
  return objectToString.call(obj);
5854
5854
  }
5855
5855
  function nameOf(f) {
@@ -6158,7 +6158,7 @@ var syntax = SyntaxError;
6158
6158
  var uri = URIError;
6159
6159
  var abs$1 = Math.abs;
6160
6160
  var floor$1 = Math.floor;
6161
- var max$1 = Math.max;
6161
+ var max$2 = Math.max;
6162
6162
  var min$1 = Math.min;
6163
6163
  var pow$1 = Math.pow;
6164
6164
  var round$1 = Math.round;
@@ -6287,99 +6287,78 @@ function requireObject_getPrototypeOf() {
6287
6287
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
6288
6288
  return Object_getPrototypeOf;
6289
6289
  }
6290
- var implementation;
6291
- var hasRequiredImplementation;
6292
- function requireImplementation() {
6293
- if (hasRequiredImplementation) return implementation;
6294
- hasRequiredImplementation = 1;
6295
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
6296
- var toStr2 = Object.prototype.toString;
6297
- var max2 = Math.max;
6298
- var funcType = "[object Function]";
6299
- var concatty = function concatty2(a, b) {
6300
- var arr = [];
6301
- for (var i = 0; i < a.length; i += 1) {
6302
- arr[i] = a[i];
6303
- }
6304
- for (var j = 0; j < b.length; j += 1) {
6305
- arr[j + a.length] = b[j];
6306
- }
6307
- return arr;
6308
- };
6309
- var slicy = function slicy2(arrLike, offset) {
6310
- var arr = [];
6311
- for (var i = offset, j = 0; i < arrLike.length; i += 1, j += 1) {
6312
- arr[j] = arrLike[i];
6313
- }
6314
- return arr;
6315
- };
6316
- var joiny = function(arr, joiner) {
6317
- var str = "";
6318
- for (var i = 0; i < arr.length; i += 1) {
6319
- str += arr[i];
6320
- if (i + 1 < arr.length) {
6321
- str += joiner;
6322
- }
6290
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
6291
+ var toStr = Object.prototype.toString;
6292
+ var max$1 = Math.max;
6293
+ var funcType = "[object Function]";
6294
+ var concatty = function concatty2(a, b) {
6295
+ var arr = [];
6296
+ for (var i = 0; i < a.length; i += 1) {
6297
+ arr[i] = a[i];
6298
+ }
6299
+ for (var j = 0; j < b.length; j += 1) {
6300
+ arr[j + a.length] = b[j];
6301
+ }
6302
+ return arr;
6303
+ };
6304
+ var slicy = function slicy2(arrLike, offset) {
6305
+ var arr = [];
6306
+ for (var i = offset, j = 0; i < arrLike.length; i += 1, j += 1) {
6307
+ arr[j] = arrLike[i];
6308
+ }
6309
+ return arr;
6310
+ };
6311
+ var joiny = function(arr, joiner) {
6312
+ var str = "";
6313
+ for (var i = 0; i < arr.length; i += 1) {
6314
+ str += arr[i];
6315
+ if (i + 1 < arr.length) {
6316
+ str += joiner;
6323
6317
  }
6324
- return str;
6325
- };
6326
- implementation = function bind2(that) {
6327
- var target = this;
6328
- if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
6329
- throw new TypeError(ERROR_MESSAGE + target);
6330
- }
6331
- var args = slicy(arguments, 1);
6332
- var bound;
6333
- var binder = function() {
6334
- if (this instanceof bound) {
6335
- var result = target.apply(
6336
- this,
6337
- concatty(args, arguments)
6338
- );
6339
- if (Object(result) === result) {
6340
- return result;
6341
- }
6342
- return this;
6343
- }
6344
- return target.apply(
6345
- that,
6318
+ }
6319
+ return str;
6320
+ };
6321
+ var implementation$1 = function bind(that) {
6322
+ var target = this;
6323
+ if (typeof target !== "function" || toStr.apply(target) !== funcType) {
6324
+ throw new TypeError(ERROR_MESSAGE + target);
6325
+ }
6326
+ var args = slicy(arguments, 1);
6327
+ var bound;
6328
+ var binder = function() {
6329
+ if (this instanceof bound) {
6330
+ var result = target.apply(
6331
+ this,
6346
6332
  concatty(args, arguments)
6347
6333
  );
6348
- };
6349
- var boundLength = max2(0, target.length - args.length);
6350
- var boundArgs = [];
6351
- for (var i = 0; i < boundLength; i++) {
6352
- boundArgs[i] = "$" + i;
6353
- }
6354
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
6355
- if (target.prototype) {
6356
- var Empty = function Empty2() {
6357
- };
6358
- Empty.prototype = target.prototype;
6359
- bound.prototype = new Empty();
6360
- Empty.prototype = null;
6334
+ if (Object(result) === result) {
6335
+ return result;
6336
+ }
6337
+ return this;
6361
6338
  }
6362
- return bound;
6339
+ return target.apply(
6340
+ that,
6341
+ concatty(args, arguments)
6342
+ );
6363
6343
  };
6364
- return implementation;
6365
- }
6366
- var functionBind;
6367
- var hasRequiredFunctionBind;
6368
- function requireFunctionBind() {
6369
- if (hasRequiredFunctionBind) return functionBind;
6370
- hasRequiredFunctionBind = 1;
6371
- var implementation2 = requireImplementation();
6372
- functionBind = Function.prototype.bind || implementation2;
6373
- return functionBind;
6374
- }
6375
- var functionCall;
6376
- var hasRequiredFunctionCall;
6377
- function requireFunctionCall() {
6378
- if (hasRequiredFunctionCall) return functionCall;
6379
- hasRequiredFunctionCall = 1;
6380
- functionCall = Function.prototype.call;
6381
- return functionCall;
6382
- }
6344
+ var boundLength = max$1(0, target.length - args.length);
6345
+ var boundArgs = [];
6346
+ for (var i = 0; i < boundLength; i++) {
6347
+ boundArgs[i] = "$" + i;
6348
+ }
6349
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
6350
+ if (target.prototype) {
6351
+ var Empty = function Empty2() {
6352
+ };
6353
+ Empty.prototype = target.prototype;
6354
+ bound.prototype = new Empty();
6355
+ Empty.prototype = null;
6356
+ }
6357
+ return bound;
6358
+ };
6359
+ var implementation = implementation$1;
6360
+ var functionBind = Function.prototype.bind || implementation;
6361
+ var functionCall = Function.prototype.call;
6383
6362
  var functionApply;
6384
6363
  var hasRequiredFunctionApply;
6385
6364
  function requireFunctionApply() {
@@ -6389,14 +6368,14 @@ function requireFunctionApply() {
6389
6368
  return functionApply;
6390
6369
  }
6391
6370
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
6392
- var bind$2 = requireFunctionBind();
6371
+ var bind$2 = functionBind;
6393
6372
  var $apply$1 = requireFunctionApply();
6394
- var $call$2 = requireFunctionCall();
6373
+ var $call$2 = functionCall;
6395
6374
  var $reflectApply = reflectApply;
6396
6375
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
6397
- var bind$1 = requireFunctionBind();
6376
+ var bind$1 = functionBind;
6398
6377
  var $TypeError$4 = type;
6399
- var $call$1 = requireFunctionCall();
6378
+ var $call$1 = functionCall;
6400
6379
  var $actualApply = actualApply;
6401
6380
  var callBindApplyHelpers = function callBindBasic(args) {
6402
6381
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -6462,8 +6441,8 @@ function requireHasown() {
6462
6441
  hasRequiredHasown = 1;
6463
6442
  var call = Function.prototype.call;
6464
6443
  var $hasOwn = Object.prototype.hasOwnProperty;
6465
- var bind2 = requireFunctionBind();
6466
- hasown = bind2.call(call, $hasOwn);
6444
+ var bind3 = functionBind;
6445
+ hasown = bind3.call(call, $hasOwn);
6467
6446
  return hasown;
6468
6447
  }
6469
6448
  var undefined$1;
@@ -6477,7 +6456,7 @@ var $TypeError$3 = type;
6477
6456
  var $URIError = uri;
6478
6457
  var abs = abs$1;
6479
6458
  var floor = floor$1;
6480
- var max = max$1;
6459
+ var max = max$2;
6481
6460
  var min = min$1;
6482
6461
  var pow = pow$1;
6483
6462
  var round = round$1;
@@ -6511,7 +6490,7 @@ var getProto = requireGetProto();
6511
6490
  var $ObjectGPO = requireObject_getPrototypeOf();
6512
6491
  var $ReflectGPO = requireReflect_getPrototypeOf();
6513
6492
  var $apply = requireFunctionApply();
6514
- var $call = requireFunctionCall();
6493
+ var $call = functionCall;
6515
6494
  var needsEval = {};
6516
6495
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
6517
6496
  var INTRINSICS = {
@@ -6681,13 +6660,13 @@ var LEGACY_ALIASES = {
6681
6660
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
6682
6661
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
6683
6662
  };
6684
- var bind = requireFunctionBind();
6663
+ var bind2 = functionBind;
6685
6664
  var hasOwn = requireHasown();
6686
- var $concat = bind.call($call, Array.prototype.concat);
6687
- var $spliceApply = bind.call($apply, Array.prototype.splice);
6688
- var $replace = bind.call($call, String.prototype.replace);
6689
- var $strSlice = bind.call($call, String.prototype.slice);
6690
- var $exec = bind.call($call, RegExp.prototype.exec);
6665
+ var $concat = bind2.call($call, Array.prototype.concat);
6666
+ var $spliceApply = bind2.call($apply, Array.prototype.splice);
6667
+ var $replace = bind2.call($call, String.prototype.replace);
6668
+ var $strSlice = bind2.call($call, String.prototype.slice);
6669
+ var $exec = bind2.call($call, RegExp.prototype.exec);
6691
6670
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
6692
6671
  var reEscapeChar = /\\(\\)?/g;
6693
6672
  var stringToPath = function stringToPath2(string) {
@@ -3,9 +3,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const admin = require("@strapi/strapi/admin");
5
5
  const reactRouterDom = require("react-router-dom");
6
- const index = require("./index-DHhRVslt.js");
6
+ const index = require("./index-BAXZ3d__.js");
7
7
  const reactQuery = require("@tanstack/react-query");
8
- const index$1 = require("./index-_4jTpBrc.js");
8
+ const index$1 = require("./index-CJVLjLWX.js");
9
9
  const react = require("zustand/react");
10
10
  const React = require("react");
11
11
  const styled = require("styled-components");
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-DHhRVslt.js");
2
+ const index = require("../_chunks/index-BAXZ3d__.js");
3
3
  require("react");
4
4
  module.exports = index.index;
@@ -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.5",
4
4
  "description": "Strapi - Comments plugin",
5
5
  "strapi": {
6
6
  "name": "comments",