@7365admin1/core 3.48.1-staging.193 → 3.48.1-staging.194

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Scope the bulletin video routes to their estate. `POST /api/bulletin-videos`, the list, the by-id read, the update and the delete carried `requireAuth` and nothing more, so any signed-in account on the platform could publish a video into another client's estate, list that estate's videos, or read, rewrite and delete any video by its id alone. Reach is now decided from the session — on the site named in the request for the write and the list, and on the stored row for the three by-id routes.
package/dist/index.js CHANGED
@@ -68057,6 +68057,14 @@ function useBulletinVideoController() {
68057
68057
  getBulletinVideoById: _getBulletinVideoById,
68058
68058
  deleteBulletinVideoById: _deleteBulletinVideoById
68059
68059
  } = useBulletinVideoRepo();
68060
+ async function requireBulletinVideoReach(req, id) {
68061
+ const video = await _getBulletinVideoById(id);
68062
+ const { canReach } = await siteReachOf(req);
68063
+ if (!await canReach(video)) {
68064
+ throw new import_node_server_utils203.NotFoundError("Bulletin video not found.");
68065
+ }
68066
+ return video;
68067
+ }
68060
68068
  async function add(req, res, next) {
68061
68069
  try {
68062
68070
  const { error, value } = schemaBulletinVideo.validate(req.body, {
@@ -68068,6 +68076,7 @@ function useBulletinVideoController() {
68068
68076
  next(new import_node_server_utils203.BadRequestError(messages));
68069
68077
  return;
68070
68078
  }
68079
+ await requireSiteReach(req, value.site);
68071
68080
  const data = await _add(value);
68072
68081
  res.status(201).json(data);
68073
68082
  return;
@@ -68102,6 +68111,7 @@ function useBulletinVideoController() {
68102
68111
  [sort ?? "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
68103
68112
  };
68104
68113
  try {
68114
+ await requireSiteReach(req, site);
68105
68115
  const data = await _getAll({
68106
68116
  search,
68107
68117
  page,
@@ -68131,7 +68141,7 @@ function useBulletinVideoController() {
68131
68141
  return;
68132
68142
  }
68133
68143
  const { _id } = value;
68134
- const data = await _getBulletinVideoById(_id);
68144
+ const data = await requireBulletinVideoReach(req, _id);
68135
68145
  res.status(200).json(data);
68136
68146
  return;
68137
68147
  } catch (error) {
@@ -68153,6 +68163,7 @@ function useBulletinVideoController() {
68153
68163
  return;
68154
68164
  }
68155
68165
  try {
68166
+ await requireBulletinVideoReach(req, _id);
68156
68167
  const result = await _updateBulletinVideoById(_id, req.body);
68157
68168
  res.status(200).json({ message: result });
68158
68169
  return;
@@ -68174,6 +68185,7 @@ function useBulletinVideoController() {
68174
68185
  return;
68175
68186
  }
68176
68187
  const { _id } = value;
68188
+ await requireBulletinVideoReach(req, _id);
68177
68189
  await _deleteBulletinVideoById(_id);
68178
68190
  res.status(200).json({ message: "Successfully deleted bulletin video." });
68179
68191
  return;