@7365admin1/core 3.52.14 → 3.52.15

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/dist/index.mjs CHANGED
@@ -34005,6 +34005,7 @@ function useCustomerController() {
34005
34005
  }
34006
34006
  });
34007
34007
  try {
34008
+ await requireOrgReach(req, org);
34008
34009
  const data = await _getAll({
34009
34010
  search,
34010
34011
  page,
@@ -86963,7 +86964,8 @@ function usePostPrelovedRepo() {
86963
86964
  status,
86964
86965
  category,
86965
86966
  subcategory,
86966
- userId
86967
+ userId,
86968
+ siteScope = null
86967
86969
  }, session) {
86968
86970
  page = page > 0 ? page - 1 : 0;
86969
86971
  if (site) {
@@ -86992,7 +86994,15 @@ function usePostPrelovedRepo() {
86992
86994
  }
86993
86995
  }
86994
86996
  const query2 = {
86995
- status: { $ne: "deleted" /* DELETED */ },
86997
+ // `$ne` and `$in` are both operators on the SAME field, so Mongo ANDs
86998
+ // them: a caller-supplied `status` narrows the answer but can never
86999
+ // widen it back to deleted rows. Written as one object rather than two
87000
+ // spreads because the second spread REPLACED the key - `?status=deleted`
87001
+ // listed every soft-deleted post the noticeboard had hidden.
87002
+ status: {
87003
+ $ne: "deleted" /* DELETED */,
87004
+ ...status && { $in: Array.isArray(status) ? status : [status] }
87005
+ },
86996
87006
  ...site && { site },
86997
87007
  ...search && {
86998
87008
  $or: [
@@ -87000,9 +87010,16 @@ function usePostPrelovedRepo() {
87000
87010
  { description: { $regex: search, $options: "i" } }
87001
87011
  ]
87002
87012
  },
87003
- ...status && {
87004
- status: { $in: Array.isArray(status) ? status : [status] }
87005
- },
87013
+ // The sites this caller may be shown, set only when the request named NO
87014
+ // site - see `entitledSites`. Applied inside the query so the page counts
87015
+ // describe what the caller can actually see. An EMPTY array is a real
87016
+ // answer: `$in: []` matches nothing, which is the fail-closed side, so it
87017
+ // is deliberately not collapsed into the falsy branch alongside `null`.
87018
+ ...siteScope ? {
87019
+ site: {
87020
+ $in: siteScope.filter((id) => ObjectId166.isValid(id)).map((id) => new ObjectId166(id))
87021
+ }
87022
+ } : {},
87006
87023
  ...categoryId && { category: categoryId },
87007
87024
  ...subcategoryIds && { subcategory: { $in: subcategoryIds } }
87008
87025
  };
@@ -87115,7 +87132,14 @@ function usePostPrelovedRepo() {
87115
87132
  });
87116
87133
  }
87117
87134
  const query2 = {
87118
- status: { $ne: "deleted" /* DELETED */ },
87135
+ // Same merge as `getAll` above, and for the same reason: the second
87136
+ // spread replaced the key, so `?status=deleted` returned this owner's
87137
+ // soft-deleted posts. Scope is unchanged here - the list is already
87138
+ // bounded to one `createdBy`.
87139
+ status: {
87140
+ $ne: "deleted" /* DELETED */,
87141
+ ...status && { $in: Array.isArray(status) ? status : [status] }
87142
+ },
87119
87143
  createdBy: ownerObjectId,
87120
87144
  ...site && { site },
87121
87145
  ...search && {
@@ -87124,9 +87148,6 @@ function usePostPrelovedRepo() {
87124
87148
  { description: { $regex: search, $options: "i" } }
87125
87149
  ]
87126
87150
  },
87127
- ...status && {
87128
- status: { $in: Array.isArray(status) ? status : [status] }
87129
- },
87130
87151
  ...categoryIds && { category: { $in: categoryIds } }
87131
87152
  };
87132
87153
  const sortObj = buildSortObj(filter);
@@ -87532,12 +87553,16 @@ function usePostPrelovedController() {
87532
87553
  userId
87533
87554
  } = value;
87534
87555
  try {
87556
+ const siteScope = site ? null : await entitledSites(req);
87557
+ if (site)
87558
+ await requireSiteReach(req, site);
87535
87559
  const data = await _getAll({
87536
87560
  page,
87537
87561
  limit,
87538
87562
  search,
87539
87563
  filter,
87540
87564
  site,
87565
+ siteScope,
87541
87566
  status: status ? Array.isArray(status) ? status : [status] : void 0,
87542
87567
  category: category ?? void 0,
87543
87568
  subcategory: subcategory ? Array.isArray(subcategory) ? subcategory : [subcategory] : void 0,