@7365admin1/core 3.32.2-staging.81 → 3.32.2-staging.83

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,17 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Make the "an invitation is already waiting" check actually find the invitation
6
+
7
+ The duplicate-invitation guard added with the existing-provider invite fix never
8
+ fired. Invitations are written with `metadata.siteId` as an ObjectId, but the
9
+ lookup searched for the site id as the plain string it arrived as on the request,
10
+ and MongoDB does not treat the two as equal. The query therefore always came back
11
+ empty: a property manager could send the same service provider a second, third
12
+ and fourth invitation for the same site while the first was still valid, and each
13
+ one produced another email and another pending row for them to chase.
14
+
15
+ The lookup now matches either form, so older records that hold the string are
16
+ still found. Nothing else changes: the refusal message and the status code are
17
+ the ones already shipped.
package/dist/index.d.ts CHANGED
@@ -9594,12 +9594,20 @@ declare function useNotificationRepo(): {
9594
9594
  pageRange: string;
9595
9595
  }>;
9596
9596
  markAsReadById: (_id: string, userId: string) => Promise<mongodb.WithId<TNotification>>;
9597
+ markAllAsRead: (userId: string, appSlug?: string) => Promise<{
9598
+ modifiedCount: number;
9599
+ }>;
9600
+ getUnreadCount: (userId: string, appSlug?: string) => Promise<{
9601
+ unread: number;
9602
+ }>;
9597
9603
  };
9598
9604
 
9599
9605
  declare function useNotificationController(): {
9600
9606
  add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
9601
9607
  getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
9602
9608
  markAsRead: (req: Request, res: Response, next: NextFunction) => Promise<void>;
9609
+ markAllAsRead: (req: Request, res: Response, next: NextFunction) => Promise<void>;
9610
+ getUnreadCount: (req: Request, res: Response, next: NextFunction) => Promise<void>;
9603
9611
  };
9604
9612
 
9605
9613
  export { ANPRMode, AccessTypeProps, AppServiceType, AssignCardConfig, BidStatus, BidType, BuildingLevelStatus, BuildingStatus, BulkCardUpdate, BulletinOrder, BulletinRecipient, BulletinSort, BulletinStatus, BulletinVideoOrder, BulletinVideoSort, CAMERA_ANPR_PERMISSIONS, CAMERA_CAPABILITIES, CAMERA_CAPABILITY_REASONS, CAMERA_NOT_PATROL_OR_CCTV, CAMERA_PTZ_PERMISSIONS, CAMERA_REQUEST_TIMEOUT_MS, CAMERA_RTSP_TIMEOUT_MS, CAMERA_SETUP_PERMISSIONS, CAMERA_SNAPSHOT_CACHE_SECONDS, CAMERA_SNAPSHOT_MAX_BYTES, CAMERA_TEST_MIN_INTERVAL_SECONDS, CAMERA_TEST_ROUND_LIMIT, CAMERA_TEST_ROUND_SECONDS, CAMERA_TYPE_ANPR, CAMERA_TYPE_IP, CAMERA_VIEW_PERMISSIONS, CLOCK_DRIFT_WARN_SECONDS, CURRENT_TIME_ENDPOINT, Camera, CameraAddressInput, CameraCapability, CameraCapabilityContext, CameraCapabilityDescriptor, CameraCapabilityEntry, CameraCapabilityReason, CameraCapabilityState, CameraCapabilityTrace, CameraDevice, CameraMembership, CameraTestStatus, CameraTransport, CameraType, DEVICE_STATUS, DOBStatus, DayOfWeek, DeviceHttpTarget, DeviceProbeResult, DynamicFormFields, EAccessCardTypes, EAccessCardUserTypes, EmailSender, EntryOrder, EntrySort, EventOrder, EventSort, EventStatus, EventType, FacilitySort, FacilityStatus, FormEntryStatus, GuestSort, GuestStatus, HID_PERMISSION_CATEGORIES, IAccessCard, IAccessCardTransaction, MAX_CAMERA_CHANNEL, MAccessCard, MAccessCardTransaction, MAddress, MAttendance, MAttendanceSettings, MBidPreloved, MBillingConfiguration, MBillingItem, MBuilding, MBuildingLevel, MBuildingUnit, MBulletinBoard, MBulletinVideo, MCategoryPreloved, MChannelPreloved, MChat, MChatPreloved, MCustomer, MCustomerSite, MDocumentManagement, MEntryPassSettings, MEventManagement, MFeedback, MFile, MFormEntry, MGuestManagement, MHidAmicoEvent, MHidAmicoIdentity, MHidAmicoReader, MHidSipAccount, MHidSitePermissions, MIncidentReport, MManpowerDesignations, MManpowerMonitoring, MManpowerRemarks, MManpowerSites, MMember, MNfcPatrolLog, MNfcPatrolRoute, MNfcPatrolSettings, MNfcPatrolSettingsUpdate, MNfcPatrolTag, MNotification, MOccurrenceBook, MOccurrenceEntry, MOccurrenceSubject, MOnlineForm, MOrg, MOvernightParkingApprovalHours, MOvernightParkingRequest, MPatrolLog, MPatrolQuestion, MPatrolRoute, MPerson, MPost, MPostFavorite, MPromoCode, MRobot, MRole, MRoleV2, MServiceProvider, MServiceProviderBilling, MSession, MSite, MSiteCamera, MSiteFacility, MSiteFacilityBooking, MStatementOfAccount, MSubcategoryPreloved, MSubscription, MSubscriptionPlan, MUnitBilling, MUser, MVehicle, MVehicleTransaction, MVerification, MVerificationV2, MVisitorTransaction, MWorkOrder, NotificationAppSlug, NotificationModule, OrgNature, OvernightParkingRequestSort, OvernightParkingRequestStatus, PATROL_CCTV_CAMERA_FILTER, PERSON_TYPES, PStatus, PTZ_ALLOWED_ACTIONS, PTZ_ALLOWED_CODES, Period, PersonStatus, PersonType, PersonTypes, PostOrder, PostSort, PostStatus, QrTagProps, ResidentAppModuleKey, SOFTWARE_VERSION_ENDPOINT, SiteAddress, SiteCategories, SiteStatus, SortFields, SortOrder, Status, SubjectOrder, SubjectSort, SubscriptionType, TAccessMngmntSettings, TActionStatus, TAddress, TAffectedEntities, TAffectedInjured, TAppServiceType, TApprovedBy, TApprover, TAttendance, TAttendanceCheckIn, TAttendanceCheckOut, TAttendanceCheckTime, TAttendanceLocation, TAttendanceSettings, TAttendanceSettingsGetBySite, TAuthorities, TAuthoritiesCalled, TBidPreloved, TBilling, TBillingConfiguration, TBillingItem, TBuilding, TBuildingLevel, TBuildingUnit, TBulletinBoard, TBulletinVideo, TCamera, TCategoryPreloved, TChannelPreloved, TChat, TChatPreloved, TCheckPoint$1 as TCheckPoint, TComplaintInfo, TComplaintReceivedTo, TCounter, TCreateNfcPatrolLog, TCustomer, TCustomerSite, TDayNumber, TDaySchedule, TDefaultAccessCard, TDesignations, TDocs, TDocumentCreate, TDocumentManagement, TEntryPassSettings, TEventManagement, TFeedback, TFeedbackMetadata, TFeedbackUpdate, TFeedbackUpdateCategory, TFeedbackUpdateServiceProvider, TFeedbackUpdateStatus, TFeedbackUpdateToCompleted, TFile, TFiles, TFolderUpdate, TFormEntry, TGetAttendancesByUserQuery, TGetAttendancesQuery, TGuestManagement, THidAmicoEvent, THidAmicoIdentity, THidAmicoReader, THidPermissionAssignment, THidPermissionCategory, THidSipAccount, THidSitePermissions, TIncidentInformation, TIncidentReport, TIncidentTypeAndTime, TInvoice, TKeyRef, TManpowerDesignations, TManpowerDesignationsUpdate, TManpowerMonitoring, TManpowerMonitoringUpdate, TManpowerRemarks, TManpowerRemarksStatusUpdate, TManpowerRemarksUpdate, TManpowerSearchFilter, TManpowerSites, TMember, TMemberUpdateStatus, TMessagePreloved, TMiniRole, TNfcPatrolLog, TNfcPatrolRoute, TNfcPatrolRouteEdit, TNfcPatrolSettings, TNfcPatrolSettingsGetBySite, TNfcPatrolSettingsUpdate, TNfcPatrolTag, TNfcPatrolTagConfigureReset, TNfcPatrolTagEdit, TNfcPatrolTagUpdateData, TNotification, TOccurrenceBook, TOccurrenceEntry, TOccurrenceSubject, TOnlineForm, TOrg, TOvernightParkingApprovalHours, TOvernightParkingRequest, TPatrolLog, TPatrolQuestion, TPatrolRoute, TPerson, TPlaceOfIncident, TPlates, TPost, TPostFavorite, TPrice, TPriceType, TPromoCode, TPromoTier, TRANSPORT_DEVICE_HTTP, TRANSPORT_RELAY_PLAYER, TRANSPORT_RTSP_FRAME, TRecipientOfComplaint, TRemarks, TResident, TResidentAppModules, TRobot, TRobotMetadata, TRole, TRoleV2, TRoute, TSOABillingItem, TSOAStatus, TServiceProvider, TServiceProviderBilling, TSession, TSessionCreate, TShifts, TSignNfcPatrolLog, TSite, TSiteCamera, TSiteFacility, TSiteFacilityBooking, TSiteInfo, TSiteInformation, TSiteMetadata, TSiteUpdateBlock, TStatementOfAccount, TSubcategoryPreloved, TSubmissionForm, TSubscription, TSubscriptionPlan, TSubscriptionPlanApplication, TUnitBilling, TUnits, TUpdateFormEntry, TUpdateName, TUser, TUserCreate, TVehicle, TVehicleTransaction, TVehicleUpdate, TVerification, TVerificationMetadata, TVerificationMetadataV2, TVerificationV2, TVisitorTransaction, TWorkOrder, TWorkOrderMetadata, TWorkOrderUpdate, TWorkOrderUpdateStatus, TWorkOrderUpdateToCompleted, TanyoneDamageToProperty, UseAccessManagementRepo, UserStatus, VehicleCategory, VehicleOrder, VehicleSort, VehicleStatus, VehicleType, VerificationLinkType, VerificationStatus, VerificationSubjectType, VerificationType, VisitorSort, VisitorStatus, addressSchema, allowedFieldsSite, allowedNatures, allowedPlanApplications, attendanceSchema, attendanceSettingsSchema, building_level_namespace_collection, building_units_namespace_collection, buildings_namespace_collection, bulletin_boards_namespace_collection, cameraBaseUrl, cameraCapabilitiesFor, cameraDevices, cameraGrant, cameraHealthSummary, cameraManagePermissions, cameraTransports, chatPrelovedEvents, chatSchema, clampPtzSpeed, clockDriftSeconds, createManpowerRemarksDaily, customerSchema, deriveCameraHost, describeCameraCapabilities, designationsSchema, deviceControlEnabled, deviceHttpEnabled, deviceHttpTargets, deviceHttpTimeoutMs, deviceProbeTtlSeconds, events_namespace_collection, facility_bookings_namespace_collection, feedbackSchema, feedbacks2_namespace_collection, feedbacks_namespace_collection, ffmpegFrameArgs, ffmpegPath, formatCapabilityTrace, formatDahuaDate, guests_namespace_collection, hasAnyCapability, hasAnyPermission, incidentReport, incidentReportLog, incidents_namespace_collection, isCameraEntitled, isPatrolCctvCamera, isRelayPlayerUrl, logCamera, manpowerDesignationsSchema, manpowerEvents, manpowerMonitoringSchema, manpowerRemarksSchema, manpowerSitesSchema, mapWithLimit, nfcPatrolSettingsSchema, nfcPatrolSettingsSchemaUpdate, occurrence_book_namespace_collection, online_forms_namespace_collection, orgSchema, overnight_parking_requests_namespace_collection, parseCameraChannel, parseCameraHost, parseDahuaFind, parseDeviceTime, parseSoftwareVersion, promoCodeSchema, ptzEndpoint, publicCameraFields, registerCameraTransport, relayForRecorder, remarksSchema, resetCameraTransports, residentAppModuleKeys, residentFormEntry, resolutionRefusalReason, resolveCamera, resolveDeviceHttp, robotSchema, rtspUrl, schema, schemaAppSlugNotification, schemaApprovedBy, schemaApprover, schemaBidPreloved, schemaBilling, schemaBillingConfiguration, schemaBillingItem, schemaBuilding, schemaBuildingLevel, schemaBuildingUnit, schemaBuildingUpdateOptions, schemaBulletinBoard, schemaBulletinVideo, schemaCategoryPreloved, schemaChannelPreloved, schemaChatPreloved, schemaCreateHidAmicoIdentity, schemaCreateNfcPatrolLog, schemaCreateNotification, schemaCustomerSite, schemaDocumentManagement, schemaEntryPassSettings, schemaEventManagement, schemaFiles, schemaFormEntry, schemaGuestManagement, schemaHidAmicoConfiguration, schemaHidAmicoEvent, schemaHidAmicoExecuteActions, schemaHidAmicoIdentity, schemaHidAmicoIdentityIdParams, schemaHidAmicoIdentityQuery, schemaHidAmicoIntercomCall, schemaHidAmicoLogQuery, schemaHidAmicoNotificationParams, schemaHidAmicoObjectOperation, schemaHidAmicoReader, schemaHidAmicoReaderIdParams, schemaHidAmicoReaderListQuery, schemaHidAmicoSetConfiguration, schemaHidAmicoSiteIdParams, schemaHidAmicoSync, schemaHidAmicoUserImageParams, schemaHidAmicoUserImageUploadQuery, schemaHidAmicoVisitorImageParams, schemaHidAmicoVisitorImageUploadQuery, schemaHidAmicoVisitorQr, schemaHidPermissionCandidateQuery, schemaHidPermissionScopeQuery, schemaHidSipAccountRequest, schemaIncidentReport, schemaListNotification, schemaMultipleDocumentManagement, schemaNfcPatrolLog, schemaNfcPatrolRoute, schemaNfcPatrolTag, schemaNfcPatrolTagUpdateData, schemaNotification, schemaOccurrenceBook, schemaOccurrenceEntry, schemaOccurrenceSubject, schemaOnlineForm, schemaOvernightParkingApprovalHours, schemaOvernightParkingRequest, schemaPatrolLog, schemaPatrolQuestion, schemaPatrolRoute, schemaPerson, schemaPlate, schemaPost, schemaPostFavorite, schemaServiceProvider, schemaServiceProviderBilling, schemaSignNfcPatrolLog, schemaSiteCamera, schemaSiteFacility, schemaSiteFacilityBooking, schemaStatementOfAccount, schemaSubcategoryPreloved, schemaUnitBilling, schemaUpdateBidPreloved, schemaUpdateBuildingLevel, schemaUpdateBulletinBoard, schemaUpdateBulletinVideo, schemaUpdateCategoryPreloved, schemaUpdateChatPreloved, schemaUpdateDocumentManagement, schemaUpdateEntryPassSettings, schemaUpdateEventManagement, schemaUpdateFolderManagement, schemaUpdateFormEntry, schemaUpdateGuestManagement, schemaUpdateHidAmicoIdentity, schemaUpdateHidAmicoReader, schemaUpdateHidSitePermissions, schemaUpdateIncidentReport, schemaUpdateNotification, schemaUpdateOccurrenceBook, schemaUpdateOccurrenceEntry, schemaUpdateOccurrenceSubject, schemaUpdateOnlineForm, schemaUpdateOptions, schemaUpdateOvernightParkingRequest, schemaUpdatePatrolLog, schemaUpdatePatrolQuestion, schemaUpdatePatrolRoute, schemaUpdatePerson, schemaUpdatePost, schemaUpdatePostFavorite, schemaUpdateServiceProviderBilling, schemaUpdateSiteBillingConfiguration, schemaUpdateSiteBillingItem, schemaUpdateSiteCamera, schemaUpdateSiteFacility, schemaUpdateSiteFacilityBooking, schemaUpdateSiteUnitBilling, schemaUpdateStatementOfAccount, schemaUpdateSubcategoryPreloved, schemaUpdateVisTrans, schemaVehicleTransaction, schemaVisitorTransaction, schemeCamera, schemeLogCamera, sessionSchema, shiftSchema, siteSchema, site_people_namespace_collection, snapshotEndpoint, snapshotRefusalReason, subscriptionPlanSchema, updateRemarksStatusEod, updateRemarksisAcknowledged, updateSiteSchema, useAccessManagementController, useAddressRepo, useAttendanceController, useAttendanceRepository, useAttendanceSettingsController, useAttendanceSettingsRepository, useAttendanceSettingsService, useAuthController, useAuthControllerV2, useAuthService, useAuthServiceV2, useBidPrelovedController, useBidPrelovedRepo, useBidPrelovedService, useBuildingController, useBuildingLevelController, useBuildingLevelRepo, useBuildingLevelService, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useBulletinBoardController, useBulletinBoardRepo, useBulletinBoardService, useBulletinVideoController, useBulletinVideoRepo, useBulletinVideoService, useCameraViewController, useCameraViewService, useCategoryPrelovedController, useCategoryPrelovedRepo, useChannelPrelovedController, useChannelPrelovedRepo, useChatController, useChatPrelovedController, useChatPrelovedRepo, useChatPrelovedService, useChatRepo, useCounterModel, useCounterRepo, useCustomerController, useCustomerRepo, useCustomerSiteController, useCustomerSiteRepo, useCustomerSiteService, useDahuaService, useDashboardController, useDashboardRepo, useDocumentManagementController, useDocumentManagementRepo, useDocumentManagementService, useEntryPassSettingsController, useEntryPassSettingsRepo, useEventManagementController, useEventManagementRepo, useEventManagementService, useFeedbackController, useFeedbackRepo, useFeedbackService, useFileController, useFileRepo, useFileService, useFormEntryController, useFormEntryRepo, useGuestManagementController, useGuestManagementRepo, useGuestManagementService, useHidAmicoController, useHidAmicoRepo, useHidAmicoService, useHrmLabsAttendanceCtrl, useHrmLabsAttendanceSrvc, useIncidentReportController, useIncidentReportRepo, useIncidentReportService, useInvoiceController, useInvoiceModel, useInvoiceRepo, useManpowerDesignationCtrl, useManpowerDesignationRepo, useManpowerMonitoringCtrl, useManpowerMonitoringRepo, useManpowerMonitoringSrvc, useManpowerRemarkCtrl, useManpowerRemarksRepo, useManpowerSitesCtrl, useManpowerSitesRepo, useManpowerSitesSrvc, useMemberController, useMemberRepo, useMemberService, useNewDashboardController, useNewDashboardRepo, useNfcPatrolLogController, useNfcPatrolLogRepo, useNfcPatrolLogService, useNfcPatrolRouteController, useNfcPatrolRouteRepo, useNfcPatrolRouteService, useNfcPatrolSettingsController, useNfcPatrolSettingsRepository, useNfcPatrolSettingsService, useNfcPatrolTagController, useNfcPatrolTagRepo, useNfcPatrolTagService, useNotificationController, useNotificationRepo, useOccurrenceBookController, useOccurrenceBookRepo, useOccurrenceBookService, useOccurrenceEntryController, useOccurrenceEntryRepo, useOccurrenceEntryService, useOccurrenceSubjectController, useOccurrenceSubjectRepo, useOccurrenceSubjectService, useOnlineFormController, useOnlineFormRepo, useOrgController, useOrgControllerV2, useOrgRepo, useOvernightParkingController, useOvernightParkingRepo, useOvernightParkingRequestController, useOvernightParkingRequestRepo, useOvernightParkingRequestService, usePatrolLogController, usePatrolLogRepo, usePatrolQuestionController, usePatrolQuestionRepo, usePatrolRouteController, usePatrolRouteRepo, usePersonController, usePersonRepo, usePostFavoriteController, usePostFavoriteRepo, usePostFavoriteService, usePostPrelovedController, usePostPrelovedRepo, usePriceController, usePriceModel, usePriceRepo, usePromoCodeController, usePromoCodeRepo, useRedDotPaymentController, useRedDotPaymentRepo, useRedDotPaymentSvc, useRobotController, useRobotRepo, useRobotService, useRoleController, useRoleControllerV2, useRoleRepo, useRoleRepoV2, useRoleServiceV2, useServiceProviderBillingController, useServiceProviderBillingRepo, useServiceProviderBillingService, useServiceProviderController, useServiceProviderRepo, useSessionRepo, useSiteBillingConfigurationController, useSiteBillingConfigurationRepo, useSiteBillingItemController, useSiteBillingItemRepo, useSiteCameraController, useSiteCameraRepo, useSiteCameraService, useSiteController, useSiteFacilityBookingController, useSiteFacilityBookingRepo, useSiteFacilityBookingService, useSiteFacilityController, useSiteFacilityRepo, useSiteFacilityService, useSiteRepo, useSiteService, useSiteUnitBillingController, useSiteUnitBillingRepo, useSiteUnitBillingService, useStatementOfAccountController, useStatementOfAccountRepo, useSubcategoryPrelovedController, useSubcategoryPrelovedRepo, useSubscriptionController, useSubscriptionPlanController, useSubscriptionPlanRepo, useSubscriptionRepo, useSubscriptionService, useUserController, useUserControllerV2, useUserRepo, useUserRepoV2, useUserService, useUserServiceV2, useVehicleController, useVehicleRepo, useVehicleService, useVerificationController, useVerificationControllerV2, useVerificationRepo, useVerificationRepoV2, useVerificationService, useVerificationServiceV2, useVisitorTransactionController, useVisitorTransactionRepo, useVisitorTransactionService, useWorkOrderController, useWorkOrderRepo, useWorkOrderService, userSchema, vehicleSchema, vehicles_namespace_collection, visitorPersonRepo, visitorPersonService, visitorType, visitors_namespace_collection, wallConfig, workOrderSchema, work_orders2_namespace_collection, work_orders_namespace_collection };
package/dist/index.js CHANGED
@@ -12480,6 +12480,11 @@ function useVerificationRepoV2() {
12480
12480
  }
12481
12481
  }
12482
12482
  async function getPendingServiceProviderInvite(email, siteId) {
12483
+ const site = [siteId];
12484
+ try {
12485
+ site.push(new import_mongodb19.ObjectId(siteId));
12486
+ } catch {
12487
+ }
12483
12488
  try {
12484
12489
  return await collection.findOne(
12485
12490
  {
@@ -12491,7 +12496,7 @@ function useVerificationRepoV2() {
12491
12496
  "service-provider-create-org" /* SERVICE_PROVIDER_CREATE_ORG */
12492
12497
  ]
12493
12498
  },
12494
- "metadata.siteId": siteId,
12499
+ "metadata.siteId": { $in: site },
12495
12500
  expireAt: { $gt: (/* @__PURE__ */ new Date()).toISOString() }
12496
12501
  },
12497
12502
  { sort: { createdAt: -1 } }
@@ -38835,7 +38840,8 @@ var schemaListNotification = import_joi60.default.object({
38835
38840
  user: import_joi60.default.string().hex().length(24).optional()
38836
38841
  });
38837
38842
  var schemaAppSlugNotification = import_joi60.default.object({
38838
- appSlug: schemaNotification.extract("appSlug")
38843
+ appSlug: schemaNotification.extract("appSlug"),
38844
+ user: import_joi60.default.string().hex().length(24).required()
38839
38845
  });
38840
38846
  function MNotification(value) {
38841
38847
  const { error } = schemaNotification.validate(value);
@@ -39023,11 +39029,53 @@ function useNotificationRepo() {
39023
39029
  throw new import_node_server_utils114.InternalServerError("Failed to update notification.");
39024
39030
  }
39025
39031
  }
39032
+ async function markAllAsRead(userId, appSlug) {
39033
+ if (!import_mongodb70.ObjectId.isValid(userId)) {
39034
+ throw new import_node_server_utils114.BadRequestError("Invalid user ID format.");
39035
+ }
39036
+ try {
39037
+ const now = /* @__PURE__ */ new Date();
39038
+ const res = await collection().updateMany(
39039
+ {
39040
+ userId: new import_mongodb70.ObjectId(userId),
39041
+ hasRead: false,
39042
+ status: { $ne: "deleted" },
39043
+ ...appSlug && { appSlug }
39044
+ },
39045
+ { $set: { hasRead: true, readAt: now, updatedAt: now } }
39046
+ );
39047
+ return { modifiedCount: res.modifiedCount };
39048
+ } catch (error) {
39049
+ if (error instanceof import_node_server_utils114.AppError)
39050
+ throw error;
39051
+ import_node_server_utils114.logger.log({ level: "error", message: error.message });
39052
+ throw new import_node_server_utils114.InternalServerError("Failed to update notifications.");
39053
+ }
39054
+ }
39055
+ async function getUnreadCount(userId, appSlug) {
39056
+ if (!import_mongodb70.ObjectId.isValid(userId)) {
39057
+ throw new import_node_server_utils114.BadRequestError("Invalid user ID format.");
39058
+ }
39059
+ try {
39060
+ const unread = await collection().countDocuments({
39061
+ userId: new import_mongodb70.ObjectId(userId),
39062
+ status: { $ne: "deleted" },
39063
+ hasRead: false,
39064
+ ...appSlug && { appSlug }
39065
+ });
39066
+ return { unread };
39067
+ } catch (error) {
39068
+ import_node_server_utils114.logger.log({ level: "error", message: error.message });
39069
+ throw new import_node_server_utils114.InternalServerError("Failed to retrieve unread count.");
39070
+ }
39071
+ }
39026
39072
  return {
39027
39073
  createIndexes,
39028
39074
  addMany,
39029
39075
  getByUserId,
39030
- markAsReadById
39076
+ markAsReadById,
39077
+ markAllAsRead,
39078
+ getUnreadCount
39031
39079
  };
39032
39080
  }
39033
39081
 
@@ -39074,6 +39122,7 @@ var NotificationService = class {
39074
39122
  status: payload.status,
39075
39123
  module: "feedback",
39076
39124
  screen: "/(user)/bulletinInfo",
39125
+ siteId: payload.siteId?.toString(),
39077
39126
  params: {
39078
39127
  id: payload.bulletinId.toString()
39079
39128
  }
@@ -39126,6 +39175,7 @@ var NotificationService = class {
39126
39175
  status: payload.status,
39127
39176
  module: "onlineForm",
39128
39177
  screen,
39178
+ siteId: payload.siteId?.toString(),
39129
39179
  params
39130
39180
  },
39131
39181
  false,
@@ -39142,6 +39192,7 @@ var NotificationService = class {
39142
39192
  status: payload.status,
39143
39193
  module: "feedback",
39144
39194
  screen: "/(user)/(bulletin-board)",
39195
+ siteId: payload.siteId?.toString(),
39145
39196
  params: {
39146
39197
  id: payload.bulletinId.toString()
39147
39198
  }
@@ -39160,6 +39211,7 @@ var NotificationService = class {
39160
39211
  status: payload.status,
39161
39212
  module: "event",
39162
39213
  screen: "/(user)/(events)",
39214
+ siteId: payload.siteId?.toString(),
39163
39215
  params: {
39164
39216
  id: payload.eventId.toString()
39165
39217
  }
@@ -39195,6 +39247,7 @@ var NotificationService = class {
39195
39247
  status: payload.status,
39196
39248
  module: "bulletinBoard",
39197
39249
  screen: "/(user)/bulletinInfo",
39250
+ siteId: payload.siteId?.toString(),
39198
39251
  params: {
39199
39252
  id: payload.bulletinId.toString()
39200
39253
  }
@@ -46720,14 +46773,16 @@ function useBulletinBoardService() {
46720
46773
  to: userIds,
46721
46774
  bulletinId: bulletinBoardId,
46722
46775
  subject: "Bulletin Board",
46723
- status: bulletinBoardStatus
46776
+ status: bulletinBoardStatus,
46777
+ siteId
46724
46778
  });
46725
46779
  }
46726
46780
  NotificationService.bulletinBoardCreatedForMA({
46727
46781
  to: userIds,
46728
46782
  bulletinId: bulletinBoardId,
46729
46783
  subject: "Bulletin Board",
46730
- status: bulletinBoardStatus
46784
+ status: bulletinBoardStatus,
46785
+ siteId
46731
46786
  });
46732
46787
  }
46733
46788
  if (recipients?.find((item) => item === "mechanical_electrical")) {
@@ -46744,7 +46799,8 @@ function useBulletinBoardService() {
46744
46799
  to: users2,
46745
46800
  bulletinId: bulletinBoardId,
46746
46801
  subject: "Bulletin Board",
46747
- status: bulletinBoardStatus
46802
+ status: bulletinBoardStatus,
46803
+ siteId
46748
46804
  },
46749
46805
  "iservice365-m-and-e-mobile-app"
46750
46806
  );
@@ -46763,7 +46819,8 @@ function useBulletinBoardService() {
46763
46819
  to: users2,
46764
46820
  bulletinId: bulletinBoardId,
46765
46821
  subject: "Bulletin Board",
46766
- status: bulletinBoardStatus
46822
+ status: bulletinBoardStatus,
46823
+ siteId
46767
46824
  },
46768
46825
  "iservice365-pest-control-mobile-app"
46769
46826
  );
@@ -46782,7 +46839,8 @@ function useBulletinBoardService() {
46782
46839
  to: users2,
46783
46840
  bulletinId: bulletinBoardId,
46784
46841
  subject: "Bulletin Board",
46785
- status: bulletinBoardStatus
46842
+ status: bulletinBoardStatus,
46843
+ siteId
46786
46844
  },
46787
46845
  "iservice365-pool-maintenance-mobile-app"
46788
46846
  );
@@ -46801,7 +46859,8 @@ function useBulletinBoardService() {
46801
46859
  to: users2,
46802
46860
  bulletinId: bulletinBoardId,
46803
46861
  subject: "Bulletin Board",
46804
- status: bulletinBoardStatus
46862
+ status: bulletinBoardStatus,
46863
+ siteId
46805
46864
  },
46806
46865
  "iservice365-landscaping-mobile-app"
46807
46866
  );
@@ -46820,7 +46879,8 @@ function useBulletinBoardService() {
46820
46879
  to: users2,
46821
46880
  bulletinId: bulletinBoardId,
46822
46881
  subject: "Bulletin Board",
46823
- status: bulletinBoardStatus
46882
+ status: bulletinBoardStatus,
46883
+ siteId
46824
46884
  },
46825
46885
  "iservice365-hygiene-mobile-app"
46826
46886
  );
@@ -48761,7 +48821,8 @@ function useEventManagementService() {
48761
48821
  NotificationService.eventCreatedForMA({
48762
48822
  to: userIds,
48763
48823
  eventId: response,
48764
- status: value.status
48824
+ status: value.status,
48825
+ siteId: value.site
48765
48826
  });
48766
48827
  }
48767
48828
  await session?.commitTransaction();
@@ -74181,7 +74242,8 @@ function useFormEntryRepo() {
74181
74242
  await NotificationService.onlineFormRequestStatusUpdated({
74182
74243
  to: userId,
74183
74244
  onlineFormId: onlineFormRequest._id,
74184
- status: onlineFormRequest.status
74245
+ status: onlineFormRequest.status,
74246
+ siteId: onlineFormRequest.site
74185
74247
  });
74186
74248
  return res.modifiedCount;
74187
74249
  } catch (error) {
@@ -77973,7 +78035,9 @@ function useNotificationController() {
77973
78035
  const {
77974
78036
  addMany: _addMany,
77975
78037
  getByUserId: _getByUserId,
77976
- markAsReadById: _markAsReadById
78038
+ markAsReadById: _markAsReadById,
78039
+ markAllAsRead: _markAllAsRead,
78040
+ getUnreadCount: _getUnreadCount
77977
78041
  } = useNotificationRepo();
77978
78042
  async function add(req, res, next) {
77979
78043
  const { error, value } = schemaCreateNotification.validate(req.body);
@@ -78042,10 +78106,47 @@ function useNotificationController() {
78042
78106
  return;
78043
78107
  }
78044
78108
  }
78109
+ async function markAllAsRead(req, res, next) {
78110
+ const { error, value } = schemaAppSlugNotification.validate(req.query);
78111
+ if (error) {
78112
+ next(new import_node_server_utils271.BadRequestError(error.message));
78113
+ return;
78114
+ }
78115
+ try {
78116
+ const data = await _markAllAsRead(value.user, value.appSlug || void 0);
78117
+ res.status(200).json({ message: "success", data });
78118
+ return;
78119
+ } catch (error2) {
78120
+ import_node_server_utils271.logger.log({ level: "error", message: error2.message });
78121
+ next(error2);
78122
+ return;
78123
+ }
78124
+ }
78125
+ async function getUnreadCount(req, res, next) {
78126
+ const { error, value } = schemaAppSlugNotification.validate(req.query);
78127
+ if (error) {
78128
+ next(new import_node_server_utils271.BadRequestError(error.message));
78129
+ return;
78130
+ }
78131
+ try {
78132
+ const data = await _getUnreadCount(
78133
+ value.user,
78134
+ value.appSlug || void 0
78135
+ );
78136
+ res.status(200).json({ data });
78137
+ return;
78138
+ } catch (error2) {
78139
+ import_node_server_utils271.logger.log({ level: "error", message: error2.message });
78140
+ next(error2);
78141
+ return;
78142
+ }
78143
+ }
78045
78144
  return {
78046
78145
  add,
78047
78146
  getAll,
78048
- markAsRead
78147
+ markAsRead,
78148
+ markAllAsRead,
78149
+ getUnreadCount
78049
78150
  };
78050
78151
  }
78051
78152
  // Annotate the CommonJS export names for ESM import in node: