@7365admin1/core 3.52.3-staging.244 → 3.52.3-staging.245

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,16 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Stop silently discarding a bulletin whose recipients include a service app with no users.
6
+
7
+ `POST /api/bulletin-boards` inserts the announcement inside a Mongo transaction and then
8
+ notifies each recipient group. The five per-service-app blocks each carried a bare `return;` for
9
+ "this site has no id" and "this app has no registered users". Those returns left the enclosing
10
+ `try` before `commitTransaction()`, so the session was ended with the transaction still open and
11
+ the announcement was rolled back — while the controller still answered `201 Created`. Selecting
12
+ Cleaning, M&E, Pest Control, Landscaping or Pool Maintenance at an estate with no users of that
13
+ app therefore made the announcement vanish with no error anywhere.
14
+
15
+ The five blocks are now one loop over a recipient-to-app-slug map, and a missing push audience
16
+ skips one notification instead of ending the request. Same apps, same order, same payloads.
package/dist/index.d.ts CHANGED
@@ -6487,7 +6487,7 @@ declare function useBulletinBoardRepo(): {
6487
6487
  };
6488
6488
 
6489
6489
  declare function useBulletinBoardService(): {
6490
- add: (value: TBulletinBoard) => Promise<"Successfully added bulletin board." | undefined>;
6490
+ add: (value: TBulletinBoard) => Promise<string>;
6491
6491
  updateBulletinBoardById: (id: string | ObjectId, value: Partial<TBulletinBoard>) => Promise<string>;
6492
6492
  processExpiredBulletinBoards: () => Promise<void>;
6493
6493
  processUpcomingBulletinBoards: () => Promise<void>;
package/dist/index.js CHANGED
@@ -64576,6 +64576,24 @@ function useBulletinBoardRepo() {
64576
64576
  // src/services/bulletin-board.service.ts
64577
64577
  var import_node_server_utils177 = require("@7365admin1/node-server-utils");
64578
64578
  var import_mongodb112 = require("mongodb");
64579
+
64580
+ // src/utils/bulletin-service-apps.util.ts
64581
+ var BULLETIN_SERVICE_APPS = [
64582
+ ["mechanical_electrical", "iservice365-m-and-e-mobile-app"],
64583
+ ["pest_control_services", "iservice365-pest-control-mobile-app"],
64584
+ ["pool_maintenance_services", "iservice365-pool-maintenance-mobile-app"],
64585
+ ["landscaping_services", "iservice365-landscaping-mobile-app"],
64586
+ ["cleaning_services", "iservice365-hygiene-mobile-app"]
64587
+ ];
64588
+ function serviceAppsForRecipients(recipients) {
64589
+ if (!Array.isArray(recipients))
64590
+ return [];
64591
+ return BULLETIN_SERVICE_APPS.filter(
64592
+ ([recipient]) => recipients.includes(recipient)
64593
+ ).map(([recipient, appSlug]) => ({ recipient, appSlug }));
64594
+ }
64595
+
64596
+ // src/services/bulletin-board.service.ts
64579
64597
  function useBulletinBoardService() {
64580
64598
  const {
64581
64599
  add: _add,
@@ -64651,105 +64669,25 @@ function useBulletinBoardService() {
64651
64669
  siteId
64652
64670
  });
64653
64671
  }
64654
- if (recipients?.find((item) => item === "mechanical_electrical")) {
64655
- if (!siteId)
64656
- return;
64657
- const users2 = await PushTokenRepo.findUserIdsBySiteIdAndAppSlug(
64658
- siteId.toString(),
64659
- "iservice365-m-and-e-mobile-app"
64660
- );
64661
- if (users2.length <= 0)
64662
- return;
64663
- NotificationService.bulletinBoardCreatedForServiceApps(
64664
- {
64665
- to: users2,
64666
- bulletinId: bulletinBoardId,
64667
- subject: "Bulletin Board",
64668
- status: bulletinBoardStatus,
64669
- siteId
64670
- },
64671
- "iservice365-m-and-e-mobile-app"
64672
- );
64673
- }
64674
- if (recipients?.find((item) => item === "pest_control_services")) {
64675
- if (!siteId)
64676
- return;
64677
- const users2 = await PushTokenRepo.findUserIdsBySiteIdAndAppSlug(
64678
- siteId.toString(),
64679
- "iservice365-pest-control-mobile-app"
64680
- );
64681
- if (users2.length <= 0)
64682
- return;
64683
- NotificationService.bulletinBoardCreatedForServiceApps(
64684
- {
64685
- to: users2,
64686
- bulletinId: bulletinBoardId,
64687
- subject: "Bulletin Board",
64688
- status: bulletinBoardStatus,
64689
- siteId
64690
- },
64691
- "iservice365-pest-control-mobile-app"
64692
- );
64693
- }
64694
- if (recipients?.find((item) => item === "pool_maintenance_services")) {
64695
- if (!siteId)
64696
- return;
64697
- const users2 = await PushTokenRepo.findUserIdsBySiteIdAndAppSlug(
64698
- siteId.toString(),
64699
- "iservice365-pool-maintenance-mobile-app"
64700
- );
64701
- if (users2.length <= 0)
64702
- return;
64703
- NotificationService.bulletinBoardCreatedForServiceApps(
64704
- {
64705
- to: users2,
64706
- bulletinId: bulletinBoardId,
64707
- subject: "Bulletin Board",
64708
- status: bulletinBoardStatus,
64709
- siteId
64710
- },
64711
- "iservice365-pool-maintenance-mobile-app"
64712
- );
64713
- }
64714
- if (recipients?.find((item) => item === "landscaping_services")) {
64715
- if (!siteId)
64716
- return;
64717
- const users2 = await PushTokenRepo.findUserIdsBySiteIdAndAppSlug(
64718
- siteId.toString(),
64719
- "iservice365-landscaping-mobile-app"
64720
- );
64721
- if (users2.length <= 0)
64722
- return;
64723
- NotificationService.bulletinBoardCreatedForServiceApps(
64724
- {
64725
- to: users2,
64726
- bulletinId: bulletinBoardId,
64727
- subject: "Bulletin Board",
64728
- status: bulletinBoardStatus,
64729
- siteId
64730
- },
64731
- "iservice365-landscaping-mobile-app"
64732
- );
64733
- }
64734
- if (recipients?.find((item) => item === "cleaning_services")) {
64735
- if (!siteId)
64736
- return;
64737
- const users2 = await PushTokenRepo.findUserIdsBySiteIdAndAppSlug(
64738
- siteId.toString(),
64739
- "iservice365-hygiene-mobile-app"
64740
- );
64741
- if (users2.length <= 0)
64742
- return;
64743
- NotificationService.bulletinBoardCreatedForServiceApps(
64744
- {
64745
- to: users2,
64746
- bulletinId: bulletinBoardId,
64747
- subject: "Bulletin Board",
64748
- status: bulletinBoardStatus,
64749
- siteId
64750
- },
64751
- "iservice365-hygiene-mobile-app"
64752
- );
64672
+ if (siteId) {
64673
+ for (const { appSlug } of serviceAppsForRecipients(recipients)) {
64674
+ const appUsers = await PushTokenRepo.findUserIdsBySiteIdAndAppSlug(
64675
+ siteId.toString(),
64676
+ appSlug
64677
+ );
64678
+ if (appUsers.length <= 0)
64679
+ continue;
64680
+ NotificationService.bulletinBoardCreatedForServiceApps(
64681
+ {
64682
+ to: appUsers,
64683
+ bulletinId: bulletinBoardId,
64684
+ subject: "Bulletin Board",
64685
+ status: bulletinBoardStatus,
64686
+ siteId
64687
+ },
64688
+ appSlug
64689
+ );
64690
+ }
64753
64691
  }
64754
64692
  await session?.commitTransaction();
64755
64693
  return "Successfully added bulletin board.";