@ozdao/martyrs 0.2.489 → 0.2.491
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/_virtual/index.cjs +4 -4
- package/dist/_virtual/index.js +4 -4
- package/dist/_virtual/index2.cjs +4 -4
- package/dist/_virtual/index2.js +4 -4
- package/dist/auth.server.cjs +2 -51
- package/dist/auth.server.js +1 -50
- package/dist/builder.cjs +90 -4
- package/dist/builder.js +90 -4
- package/dist/main-BhCqlPMQ.cjs +11 -0
- package/dist/{main-IVRL6IjM.js → main-YBlKbx0g.js} +1308 -1285
- package/dist/martyrs/src/components/Block/Block.vue.cjs +1 -1
- package/dist/martyrs/src/components/Block/Block.vue.js +1 -1
- package/dist/martyrs/src/components/Button/Button.vue2.cjs +48 -21
- package/dist/martyrs/src/components/Button/Button.vue2.cjs.map +1 -1
- package/dist/martyrs/src/components/Button/Button.vue2.js +49 -22
- package/dist/martyrs/src/components/Button/Button.vue2.js.map +1 -1
- package/dist/martyrs/src/components/Chips/{Chips.vue2.cjs → Chips.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Chips/Chips.vue.cjs.map +1 -0
- package/dist/martyrs/src/components/Chips/{Chips.vue2.js → Chips.vue.js} +2 -2
- package/dist/martyrs/src/components/Chips/Chips.vue.js.map +1 -0
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.cjs → Dropdown.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.js → Dropdown.vue2.js} +2 -2
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.cjs.map → Dropdown.vue2.js.map} +1 -1
- package/dist/martyrs/src/components/Feed/Carousel.vue.cjs +1 -1
- package/dist/martyrs/src/components/Feed/Carousel.vue.js +1 -1
- package/dist/martyrs/src/components/Feed/Feed.vue.cjs +2 -2
- package/dist/martyrs/src/components/Feed/Feed.vue.js +2 -2
- package/dist/martyrs/src/components/FieldTags/FieldTags.vue.cjs +1 -1
- package/dist/martyrs/src/components/FieldTags/FieldTags.vue.js +1 -1
- package/dist/martyrs/src/components/Loader/{Loader.vue2.cjs → Loader.vue.cjs} +3 -3
- package/dist/martyrs/src/components/Loader/Loader.vue.cjs.map +1 -0
- package/dist/martyrs/src/components/Loader/{Loader.vue2.js → Loader.vue.js} +3 -3
- package/dist/martyrs/src/components/Loader/Loader.vue.js.map +1 -0
- package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue2.cjs +1 -1
- package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue2.js +1 -1
- package/dist/martyrs/src/components/Tooltip/{Tooltip.vue2.cjs → Tooltip.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Tooltip/{Tooltip.vue2.js.map → Tooltip.vue.cjs.map} +1 -1
- package/dist/martyrs/src/components/Tooltip/{Tooltip.vue2.js → Tooltip.vue.js} +2 -2
- package/dist/martyrs/src/components/Tooltip/Tooltip.vue.js.map +1 -0
- package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.cjs +1 -1
- package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +2 -2
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.js +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.cjs +2 -2
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js +2 -2
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/blocks/CardEvent.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/blocks/CardEvent.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.cjs +3 -3
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.js +3 -3
- package/dist/martyrs/src/modules/events/components/sections/Feed.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/sections/Feed.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/sections/List.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/sections/List.vue.js +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/globals.client.cjs +1 -2
- package/dist/martyrs/src/modules/globals/globals.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/globals.client.js +1 -2
- package/dist/martyrs/src/modules/globals/globals.client.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.i18n.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.i18n.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs +3 -3
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +3 -3
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs +10 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js +10 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.js +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.cjs +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/forms/ArtistForm.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/forms/ArtistForm.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/layouts/MusicLayout.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/layouts/MusicLayout.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Album.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Album.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Artist.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Artist.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/SearchResults.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/SearchResults.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Track.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Track.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.js +1 -1
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.cjs +22 -8
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.js +23 -9
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.cjs +13 -15
- package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.js +14 -16
- package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationPreferences.vue.cjs +2 -2
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationPreferences.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationPreferences.vue.js +2 -2
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationPreferences.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationsList.vue.cjs +2 -2
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationsList.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationsList.vue.js +2 -2
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationsList.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.cjs +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.js +7 -7
- package/dist/martyrs/src/modules/notifications/notifications.client.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/router/notifications.router.js +4 -4
- package/dist/martyrs/src/modules/notifications/router/notifications.router.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/store/notifications.store.cjs +7 -10
- package/dist/martyrs/src/modules/notifications/store/notifications.store.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/store/notifications.store.js +7 -10
- package/dist/martyrs/src/modules/notifications/store/notifications.store.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.cjs +0 -1
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.js +0 -1
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs +2 -2
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/blocks/CardOrganization.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/DepartmentEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/DetailsTabSection.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/DetailsTabSection.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/blocks/ProductDiscounts.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/blocks/ProductDiscounts.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/elements/Image360.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/elements/Image360.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/blocks/CardSpot.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.js +1 -1
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.cjs +3 -3
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.js +3 -3
- package/dist/martyrs.cjs.js +1 -1
- package/dist/martyrs.css +1 -1
- package/dist/martyrs.es.js +1 -1
- package/dist/notifications.server.cjs +142 -44
- package/dist/notifications.server.js +142 -44
- package/dist/orders.server.cjs +155 -102
- package/dist/orders.server.js +155 -102
- package/dist/products.server.cjs +4 -0
- package/dist/products.server.js +4 -0
- package/dist/profile.schema-BGAe5VN5.js +92 -0
- package/dist/profile.schema-pidHrksV.cjs +91 -0
- package/dist/style.css +65 -247
- package/dist/{web-BXhlxo6M.cjs → web-BBmMBRv-.cjs} +1 -1
- package/dist/{web-Czi05iGG.js → web-Dqu-aCL5.js} +1 -1
- package/package.json +1 -1
- package/src/builder/rspack/rspack.config.spa.client.js +46 -1
- package/src/builder/rspack/rspack.config.ssr.client.js +43 -0
- package/src/builder/templates/page.js +1 -1
- package/src/components/Button/Button.vue +230 -196
- package/src/components/Loader/Loader.vue +1 -1
- package/src/modules/auth/controllers/middlewares/visitor.logger.js +22 -0
- package/src/modules/globals/globals.client.js +1 -1
- package/src/modules/globals/views/components/layouts/Client.vue +10 -9
- package/src/modules/notifications/FIXES.md +4 -0
- package/src/modules/notifications/components/layouts/NotificationsLayout.vue +33 -32
- package/src/modules/notifications/components/pages/Notifications.vue +10 -51
- package/src/modules/notifications/components/sections/NotificationPreferences.vue +1 -11
- package/src/modules/notifications/components/sections/NotificationsList.vue +1 -1
- package/src/modules/notifications/controllers/notifications.controller.js +50 -4
- package/src/modules/notifications/notifications.client.js +1 -1
- package/src/modules/notifications/notifications.server.js +18 -7
- package/src/modules/notifications/routes/notifications.routes.js +4 -2
- package/src/modules/notifications/services/notification.service.js +109 -38
- package/src/modules/notifications/services/telegram.service.js +1 -0
- package/src/modules/notifications/services/whatsapp.service.js +1 -0
- package/src/modules/notifications/store/notifications.store.js +25 -16
- package/src/modules/orders/components/partials/ShopCart.vue +0 -1
- package/src/modules/orders/controllers/orders.controller.js +195 -85
- package/src/modules/products/controllers/products.controller.js +4 -0
- package/dist/main-CmuUC0tl.cjs +0 -11
- package/dist/martyrs/src/components/Chips/Chips.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Chips/Chips.vue2.js.map +0 -1
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue.js.map +0 -1
- package/dist/martyrs/src/components/Loader/Loader.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Loader/Loader.vue2.js.map +0 -1
- package/dist/martyrs/src/components/Tooltip/Tooltip.vue2.cjs.map +0 -1
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/StoreDebugger.vue.cjs +0 -200
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/StoreDebugger.vue.cjs.map +0 -1
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/StoreDebugger.vue.js +0 -200
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/StoreDebugger.vue.js.map +0 -1
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/store-debugger.plugin.cjs +0 -21
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/store-debugger.plugin.cjs.map +0 -1
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/store-debugger.plugin.js +0 -21
- package/dist/martyrs/src/modules/globals/views/plugins/store-debugger/store-debugger.plugin.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.cjs +0 -9
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.js +0 -9
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/defaultOptions.cjs +0 -8
- package/dist/node_modules/date-fns/_lib/defaultOptions.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/defaultOptions.js +0 -8
- package/dist/node_modules/date-fns/_lib/defaultOptions.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/formatters.cjs +0 -653
- package/dist/node_modules/date-fns/_lib/format/formatters.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/formatters.js +0 -653
- package/dist/node_modules/date-fns/_lib/format/formatters.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.cjs +0 -63
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.js +0 -63
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/longFormatters.cjs +0 -59
- package/dist/node_modules/date-fns/_lib/format/longFormatters.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/format/longFormatters.js +0 -59
- package/dist/node_modules/date-fns/_lib/format/longFormatters.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.cjs +0 -21
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +0 -21
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/normalizeDates.cjs +0 -12
- package/dist/node_modules/date-fns/_lib/normalizeDates.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/normalizeDates.js +0 -12
- package/dist/node_modules/date-fns/_lib/normalizeDates.js.map +0 -1
- package/dist/node_modules/date-fns/_lib/protectedTokens.cjs +0 -24
- package/dist/node_modules/date-fns/_lib/protectedTokens.cjs.map +0 -1
- package/dist/node_modules/date-fns/_lib/protectedTokens.js +0 -24
- package/dist/node_modules/date-fns/_lib/protectedTokens.js.map +0 -1
- package/dist/node_modules/date-fns/constants.cjs +0 -9
- package/dist/node_modules/date-fns/constants.cjs.map +0 -1
- package/dist/node_modules/date-fns/constants.js +0 -9
- package/dist/node_modules/date-fns/constants.js.map +0 -1
- package/dist/node_modules/date-fns/constructFrom.cjs +0 -13
- package/dist/node_modules/date-fns/constructFrom.cjs.map +0 -1
- package/dist/node_modules/date-fns/constructFrom.js +0 -13
- package/dist/node_modules/date-fns/constructFrom.js.map +0 -1
- package/dist/node_modules/date-fns/differenceInCalendarDays.cjs +0 -21
- package/dist/node_modules/date-fns/differenceInCalendarDays.cjs.map +0 -1
- package/dist/node_modules/date-fns/differenceInCalendarDays.js +0 -21
- package/dist/node_modules/date-fns/differenceInCalendarDays.js.map +0 -1
- package/dist/node_modules/date-fns/format.cjs +0 -80
- package/dist/node_modules/date-fns/format.cjs.map +0 -1
- package/dist/node_modules/date-fns/format.js +0 -80
- package/dist/node_modules/date-fns/format.js.map +0 -1
- package/dist/node_modules/date-fns/getDayOfYear.cjs +0 -14
- package/dist/node_modules/date-fns/getDayOfYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/getDayOfYear.js +0 -14
- package/dist/node_modules/date-fns/getDayOfYear.js.map +0 -1
- package/dist/node_modules/date-fns/getISOWeek.cjs +0 -14
- package/dist/node_modules/date-fns/getISOWeek.cjs.map +0 -1
- package/dist/node_modules/date-fns/getISOWeek.js +0 -14
- package/dist/node_modules/date-fns/getISOWeek.js.map +0 -1
- package/dist/node_modules/date-fns/getISOWeekYear.cjs +0 -27
- package/dist/node_modules/date-fns/getISOWeekYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/getISOWeekYear.js +0 -27
- package/dist/node_modules/date-fns/getISOWeekYear.js.map +0 -1
- package/dist/node_modules/date-fns/getWeek.cjs +0 -14
- package/dist/node_modules/date-fns/getWeek.cjs.map +0 -1
- package/dist/node_modules/date-fns/getWeek.js +0 -14
- package/dist/node_modules/date-fns/getWeek.js.map +0 -1
- package/dist/node_modules/date-fns/getWeekYear.cjs +0 -31
- package/dist/node_modules/date-fns/getWeekYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/getWeekYear.js +0 -31
- package/dist/node_modules/date-fns/getWeekYear.js.map +0 -1
- package/dist/node_modules/date-fns/isDate.cjs +0 -8
- package/dist/node_modules/date-fns/isDate.cjs.map +0 -1
- package/dist/node_modules/date-fns/isDate.js +0 -8
- package/dist/node_modules/date-fns/isDate.js.map +0 -1
- package/dist/node_modules/date-fns/isValid.cjs +0 -10
- package/dist/node_modules/date-fns/isValid.cjs.map +0 -1
- package/dist/node_modules/date-fns/isValid.js +0 -10
- package/dist/node_modules/date-fns/isValid.js.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.cjs +0 -11
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +0 -11
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.cjs +0 -21
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +0 -21
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.cjs +0 -44
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js +0 -44
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.cjs +0 -17
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +0 -17
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.cjs +0 -86
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +0 -86
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.cjs +0 -37
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js +0 -37
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.cjs +0 -13
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +0 -13
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.cjs +0 -165
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js +0 -165
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.cjs +0 -123
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.js +0 -123
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.js.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US.cjs +0 -22
- package/dist/node_modules/date-fns/locale/en-US.cjs.map +0 -1
- package/dist/node_modules/date-fns/locale/en-US.js +0 -22
- package/dist/node_modules/date-fns/locale/en-US.js.map +0 -1
- package/dist/node_modules/date-fns/startOfDay.cjs +0 -11
- package/dist/node_modules/date-fns/startOfDay.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfDay.js +0 -11
- package/dist/node_modules/date-fns/startOfDay.js.map +0 -1
- package/dist/node_modules/date-fns/startOfISOWeek.cjs +0 -9
- package/dist/node_modules/date-fns/startOfISOWeek.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfISOWeek.js +0 -9
- package/dist/node_modules/date-fns/startOfISOWeek.js.map +0 -1
- package/dist/node_modules/date-fns/startOfISOWeekYear.cjs +0 -15
- package/dist/node_modules/date-fns/startOfISOWeekYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfISOWeekYear.js +0 -15
- package/dist/node_modules/date-fns/startOfISOWeekYear.js.map +0 -1
- package/dist/node_modules/date-fns/startOfWeek.cjs +0 -18
- package/dist/node_modules/date-fns/startOfWeek.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfWeek.js +0 -18
- package/dist/node_modules/date-fns/startOfWeek.js.map +0 -1
- package/dist/node_modules/date-fns/startOfWeekYear.cjs +0 -20
- package/dist/node_modules/date-fns/startOfWeekYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfWeekYear.js +0 -20
- package/dist/node_modules/date-fns/startOfWeekYear.js.map +0 -1
- package/dist/node_modules/date-fns/startOfYear.cjs +0 -12
- package/dist/node_modules/date-fns/startOfYear.cjs.map +0 -1
- package/dist/node_modules/date-fns/startOfYear.js +0 -12
- package/dist/node_modules/date-fns/startOfYear.js.map +0 -1
- package/dist/node_modules/date-fns/toDate.cjs +0 -9
- package/dist/node_modules/date-fns/toDate.cjs.map +0 -1
- package/dist/node_modules/date-fns/toDate.js +0 -9
- package/dist/node_modules/date-fns/toDate.js.map +0 -1
- package/dist/profile.schema-DchVS-Jr.js +0 -21
- package/dist/profile.schema-yQuIzngl.cjs +0 -20
package/dist/martyrs.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as e, a as o, b as d, C as r, k as t, c as l, d as i, e as p, f as u, g as n, h as M, i as S, j as c, F as m, l as C, n as F, o as g, L as h, p as b, M as k, q as x, H as B, r as T, s as U, t as f, u as w, S as D, v as E, w as I, x as L, y as P, z as q, A as y, B as A, D as j, U as v, E as z, G, m as H } from "./main-
|
|
1
|
+
import { _ as e, a as o, b as d, C as r, k as t, c as l, d as i, e as p, f as u, g as n, h as M, i as S, j as c, F as m, l as C, n as F, o as g, L as h, p as b, M as k, q as x, H as B, r as T, s as U, t as f, u as w, S as D, v as E, w as I, x as L, y as P, z as q, A as y, B as A, D as j, U as v, E as z, G, m as H } from "./main-YBlKbx0g.js";
|
|
2
2
|
export {
|
|
3
3
|
e as Address,
|
|
4
4
|
o as Breadcrumbs,
|
|
@@ -7,17 +7,53 @@ const mailing = require("./mailing-q7sR8gCV.cjs");
|
|
|
7
7
|
const admin = require("firebase-admin");
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const webpush = require("web-push");
|
|
10
|
-
const NotificationsController = (db, wss) => {
|
|
10
|
+
const NotificationsController = (db, wss, notificationService) => {
|
|
11
11
|
const create = async (req, res) => {
|
|
12
12
|
try {
|
|
13
13
|
const notification = await db.notification.create(req.body);
|
|
14
|
-
|
|
15
|
-
notificationService.processNotification(notification);
|
|
14
|
+
await notificationService.processNotification(notification);
|
|
16
15
|
return res.status(201).json(notification);
|
|
17
16
|
} catch (err) {
|
|
18
17
|
return res.status(500).json({ message: err.message });
|
|
19
18
|
}
|
|
20
19
|
};
|
|
20
|
+
const createBatch = async (req, res) => {
|
|
21
|
+
console.log("=== Batch notifications endpoint ===");
|
|
22
|
+
console.log("Request body:", JSON.stringify(req.body, null, 2));
|
|
23
|
+
try {
|
|
24
|
+
const { notifications } = req.body;
|
|
25
|
+
if (!notifications || !Array.isArray(notifications)) {
|
|
26
|
+
console.error("Invalid request: notifications array is required");
|
|
27
|
+
return res.status(400).json({ message: "notifications array is required" });
|
|
28
|
+
}
|
|
29
|
+
console.log("Creating notifications count:", notifications.length);
|
|
30
|
+
const createdNotifications = await db.notification.insertMany(notifications);
|
|
31
|
+
console.log("Created notifications:", createdNotifications.map((n) => n._id));
|
|
32
|
+
setImmediate(() => {
|
|
33
|
+
Promise.allSettled(createdNotifications.map(
|
|
34
|
+
(notif) => notificationService.processNotification(notif)
|
|
35
|
+
)).then((results) => {
|
|
36
|
+
const failures = results.filter((r) => r.status === "rejected");
|
|
37
|
+
if (failures.length > 0) {
|
|
38
|
+
console.error(
|
|
39
|
+
"Batch notification processing errors:",
|
|
40
|
+
failures.map((f) => f.reason?.message || f.reason)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
console.log(`Batch processing complete: ${results.length - failures.length}/${results.length} successful`);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return res.status(201).json({
|
|
47
|
+
message: "Batch notifications created",
|
|
48
|
+
count: createdNotifications.length
|
|
49
|
+
});
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.error("=== Batch notifications error ===");
|
|
52
|
+
console.error("Error:", err.message);
|
|
53
|
+
console.error("Stack:", err.stack);
|
|
54
|
+
return res.status(500).json({ message: err.message });
|
|
55
|
+
}
|
|
56
|
+
};
|
|
21
57
|
const getUserNotifications = async (req, res) => {
|
|
22
58
|
try {
|
|
23
59
|
const userId = req.params.userId;
|
|
@@ -52,7 +88,7 @@ const NotificationsController = (db, wss) => {
|
|
|
52
88
|
const markAllAsRead = async (req, res) => {
|
|
53
89
|
try {
|
|
54
90
|
const userId = req.params.userId;
|
|
55
|
-
const result = await db.notification.updateMany({ userId, status: "unread" }, { status: "read", updatedAt: Date.now() });
|
|
91
|
+
const result = await db.notification.updateMany({ userId, status: { $in: ["sent", "unread"] } }, { status: "read", updatedAt: Date.now() });
|
|
56
92
|
const updatedNotifications = await db.notification.find({
|
|
57
93
|
userId,
|
|
58
94
|
status: "read",
|
|
@@ -134,6 +170,7 @@ const NotificationsController = (db, wss) => {
|
|
|
134
170
|
};
|
|
135
171
|
return {
|
|
136
172
|
create,
|
|
173
|
+
createBatch,
|
|
137
174
|
getUserNotifications,
|
|
138
175
|
markAsRead,
|
|
139
176
|
registerDevice,
|
|
@@ -202,10 +239,11 @@ const UserDeviceModel = (db, additionalFields = {}) => {
|
|
|
202
239
|
schema.index({ userId: 1, deviceId: 1 }, { unique: true });
|
|
203
240
|
return db.mongoose.model("UserDevice", schema);
|
|
204
241
|
};
|
|
205
|
-
const notificationsRoutes = (app, db, wss, origins, publicPath) => {
|
|
206
|
-
const controller = NotificationsController(db, wss);
|
|
242
|
+
const notificationsRoutes = (app, db, wss, origins, publicPath, notificationService) => {
|
|
243
|
+
const controller = NotificationsController(db, wss, notificationService);
|
|
207
244
|
app.get("/api/notifications/user/:userId", controller.getUserNotifications);
|
|
208
245
|
app.post("/api/notifications", controller.create);
|
|
246
|
+
app.post("/api/notifications/batch", controller.createBatch);
|
|
209
247
|
app.put("/api/notifications/:id/read", controller.markAsRead);
|
|
210
248
|
app.put("/api/notifications/user/:userId/read-all", controller.markAllAsRead);
|
|
211
249
|
app.post("/api/notifications/devices/register", controller.registerDevice);
|
|
@@ -373,7 +411,7 @@ const NotificationService = function(db, wss) {
|
|
|
373
411
|
try {
|
|
374
412
|
const userId = notification.userId.toString();
|
|
375
413
|
const preferences = await db.notificationPreference.find({
|
|
376
|
-
userId
|
|
414
|
+
userId: new ObjectId(userId)
|
|
377
415
|
// notificationType: notification.type
|
|
378
416
|
});
|
|
379
417
|
console.log("userId", userId);
|
|
@@ -393,55 +431,106 @@ const NotificationService = function(db, wss) {
|
|
|
393
431
|
// whatsapp: sendWhatsAppNotification
|
|
394
432
|
};
|
|
395
433
|
const userDevices = await db.userDevice.find({
|
|
396
|
-
userId,
|
|
434
|
+
userId: new ObjectId(userId),
|
|
397
435
|
isActive: true
|
|
398
436
|
});
|
|
437
|
+
console.log("=== CHANNEL SELECTION DEBUG ===");
|
|
438
|
+
console.log("userDevices found:", userDevices.length);
|
|
439
|
+
console.log("userDevices:", userDevices);
|
|
440
|
+
console.log("user.email:", user.email);
|
|
441
|
+
console.log("user.phoneNumber:", user.phoneNumber);
|
|
442
|
+
console.log("preferences.length:", preferences.length);
|
|
399
443
|
let channels = ["web"];
|
|
444
|
+
if (userDevices.length > 0) {
|
|
445
|
+
channels.push("push");
|
|
446
|
+
console.log("Added push channel - devices found");
|
|
447
|
+
} else {
|
|
448
|
+
console.log("No push channel - no devices found");
|
|
449
|
+
}
|
|
400
450
|
if (user.email) {
|
|
401
451
|
channels.push("email");
|
|
452
|
+
console.log("Added email channel");
|
|
402
453
|
}
|
|
403
454
|
if (user.phoneNumber) {
|
|
404
455
|
channels.push("sms");
|
|
456
|
+
console.log("Added SMS channel");
|
|
405
457
|
}
|
|
406
458
|
if (preferences.length > 0) {
|
|
407
459
|
channels = preferences.filter((pref) => pref.isEnabled).map((pref) => pref.channelType);
|
|
460
|
+
console.log("Overridden with user preferences:", channels);
|
|
408
461
|
}
|
|
409
|
-
console.log("
|
|
462
|
+
console.log("=== FINAL CHANNELS ===", channels);
|
|
463
|
+
const channelPromises = [];
|
|
410
464
|
for (const channel of channels) {
|
|
465
|
+
console.log(`=== PREPARING CHANNEL: ${channel} ===`);
|
|
411
466
|
const sendFunc = channelRouters[channel];
|
|
412
|
-
if (sendFunc) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
error
|
|
440
|
-
|
|
441
|
-
})
|
|
467
|
+
if (!sendFunc) {
|
|
468
|
+
channelPromises.push(Promise.resolve({
|
|
469
|
+
channel,
|
|
470
|
+
success: false,
|
|
471
|
+
error: "No send function"
|
|
472
|
+
}));
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
if (channel === "push") {
|
|
476
|
+
console.log(`Preparing push to ${userDevices.length} devices`);
|
|
477
|
+
for (const device of userDevices) {
|
|
478
|
+
channelPromises.push(
|
|
479
|
+
sendFunc(notification, user, device).then(() => {
|
|
480
|
+
console.log(`Push sent successfully to device ${device.deviceId}`);
|
|
481
|
+
return { channel: "push", deviceId: device.deviceId, success: true };
|
|
482
|
+
}).catch((err) => {
|
|
483
|
+
console.error(`Push failed for device ${device.deviceId}:`, err);
|
|
484
|
+
return { channel: "push", deviceId: device.deviceId, success: false, error: err.message };
|
|
485
|
+
})
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
} else {
|
|
489
|
+
channelPromises.push(
|
|
490
|
+
sendFunc(notification, user).then(() => {
|
|
491
|
+
console.log(`${channel} notification sent successfully`);
|
|
492
|
+
return { channel, success: true };
|
|
493
|
+
}).catch((err) => {
|
|
494
|
+
console.error(`${channel} notification failed:`, err);
|
|
495
|
+
return { channel, success: false, error: err.message };
|
|
496
|
+
})
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
console.log(`=== PROCESSING ${channelPromises.length} PARALLEL OPERATIONS ===`);
|
|
501
|
+
const results = await Promise.allSettled(channelPromises);
|
|
502
|
+
const logs = [];
|
|
503
|
+
const channelSuccessMap = /* @__PURE__ */ new Map();
|
|
504
|
+
results.forEach(({ status, value }) => {
|
|
505
|
+
if (status === "fulfilled" && value) {
|
|
506
|
+
const logEntry = {
|
|
507
|
+
notificationId: notification._id,
|
|
508
|
+
userId: notification.userId,
|
|
509
|
+
channelType: value.channel,
|
|
510
|
+
status: value.success ? "sent" : "failed",
|
|
511
|
+
sentAt: Date.now()
|
|
512
|
+
};
|
|
513
|
+
if (!value.success) {
|
|
514
|
+
logEntry.error = value.error;
|
|
515
|
+
}
|
|
516
|
+
logs.push(logEntry);
|
|
517
|
+
if (value.success) {
|
|
518
|
+
channelSuccessMap.set(value.channel, true);
|
|
442
519
|
}
|
|
443
520
|
}
|
|
521
|
+
});
|
|
522
|
+
if (logs.length > 0) {
|
|
523
|
+
setImmediate(() => db.notificationLog.insertMany(logs).catch(console.error));
|
|
524
|
+
console.log(`Scheduled ${logs.length} logs for batch insertion`);
|
|
444
525
|
}
|
|
526
|
+
const hasSuccessfulSend = channelSuccessMap.size > 0;
|
|
527
|
+
console.log(`=== PROCESSING COMPLETE - Success: ${hasSuccessfulSend} ===`);
|
|
528
|
+
setImmediate(() => {
|
|
529
|
+
db.notification.findByIdAndUpdate(notification._id, {
|
|
530
|
+
status: hasSuccessfulSend ? "sent" : "failed",
|
|
531
|
+
updatedAt: Date.now()
|
|
532
|
+
}).catch(console.error);
|
|
533
|
+
});
|
|
445
534
|
} catch (error) {
|
|
446
535
|
console.error("Error processing notification:", error);
|
|
447
536
|
await db.notification.findByIdAndUpdate(notification._id, {
|
|
@@ -513,14 +602,23 @@ function initializeNotifications(app, db, wss, origins, publicPath) {
|
|
|
513
602
|
db.notificationPreference = NotificationPreferenceModel(db);
|
|
514
603
|
db.notificationLog = NotificationLogModel(db);
|
|
515
604
|
getInstance(db);
|
|
605
|
+
const notificationService = NotificationService(db, wss);
|
|
516
606
|
if (app) {
|
|
517
|
-
notificationsRoutes(app, db, wss);
|
|
607
|
+
notificationsRoutes(app, db, wss, origins, publicPath, notificationService);
|
|
518
608
|
}
|
|
519
|
-
const notificationService = NotificationService(db, wss);
|
|
520
609
|
console.log("[DEBUG] WSS in notification init:", wss);
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
610
|
+
let isProcessing = false;
|
|
611
|
+
setInterval(async () => {
|
|
612
|
+
if (isProcessing) return;
|
|
613
|
+
isProcessing = true;
|
|
614
|
+
try {
|
|
615
|
+
await notificationService.processPendingNotifications();
|
|
616
|
+
} catch (error) {
|
|
617
|
+
console.error("Error in processPendingNotifications:", error);
|
|
618
|
+
} finally {
|
|
619
|
+
isProcessing = false;
|
|
620
|
+
}
|
|
621
|
+
}, 1e4);
|
|
524
622
|
}
|
|
525
623
|
const models = {
|
|
526
624
|
NotificationModel,
|
|
@@ -5,17 +5,53 @@ import { m as mailing } from "./mailing-C11EYWm-.js";
|
|
|
5
5
|
import admin from "firebase-admin";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import webpush from "web-push";
|
|
8
|
-
const NotificationsController = (db, wss) => {
|
|
8
|
+
const NotificationsController = (db, wss, notificationService) => {
|
|
9
9
|
const create = async (req, res) => {
|
|
10
10
|
try {
|
|
11
11
|
const notification = await db.notification.create(req.body);
|
|
12
|
-
|
|
13
|
-
notificationService.processNotification(notification);
|
|
12
|
+
await notificationService.processNotification(notification);
|
|
14
13
|
return res.status(201).json(notification);
|
|
15
14
|
} catch (err) {
|
|
16
15
|
return res.status(500).json({ message: err.message });
|
|
17
16
|
}
|
|
18
17
|
};
|
|
18
|
+
const createBatch = async (req, res) => {
|
|
19
|
+
console.log("=== Batch notifications endpoint ===");
|
|
20
|
+
console.log("Request body:", JSON.stringify(req.body, null, 2));
|
|
21
|
+
try {
|
|
22
|
+
const { notifications } = req.body;
|
|
23
|
+
if (!notifications || !Array.isArray(notifications)) {
|
|
24
|
+
console.error("Invalid request: notifications array is required");
|
|
25
|
+
return res.status(400).json({ message: "notifications array is required" });
|
|
26
|
+
}
|
|
27
|
+
console.log("Creating notifications count:", notifications.length);
|
|
28
|
+
const createdNotifications = await db.notification.insertMany(notifications);
|
|
29
|
+
console.log("Created notifications:", createdNotifications.map((n) => n._id));
|
|
30
|
+
setImmediate(() => {
|
|
31
|
+
Promise.allSettled(createdNotifications.map(
|
|
32
|
+
(notif) => notificationService.processNotification(notif)
|
|
33
|
+
)).then((results) => {
|
|
34
|
+
const failures = results.filter((r) => r.status === "rejected");
|
|
35
|
+
if (failures.length > 0) {
|
|
36
|
+
console.error(
|
|
37
|
+
"Batch notification processing errors:",
|
|
38
|
+
failures.map((f) => f.reason?.message || f.reason)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
console.log(`Batch processing complete: ${results.length - failures.length}/${results.length} successful`);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
return res.status(201).json({
|
|
45
|
+
message: "Batch notifications created",
|
|
46
|
+
count: createdNotifications.length
|
|
47
|
+
});
|
|
48
|
+
} catch (err) {
|
|
49
|
+
console.error("=== Batch notifications error ===");
|
|
50
|
+
console.error("Error:", err.message);
|
|
51
|
+
console.error("Stack:", err.stack);
|
|
52
|
+
return res.status(500).json({ message: err.message });
|
|
53
|
+
}
|
|
54
|
+
};
|
|
19
55
|
const getUserNotifications = async (req, res) => {
|
|
20
56
|
try {
|
|
21
57
|
const userId = req.params.userId;
|
|
@@ -50,7 +86,7 @@ const NotificationsController = (db, wss) => {
|
|
|
50
86
|
const markAllAsRead = async (req, res) => {
|
|
51
87
|
try {
|
|
52
88
|
const userId = req.params.userId;
|
|
53
|
-
const result = await db.notification.updateMany({ userId, status: "unread" }, { status: "read", updatedAt: Date.now() });
|
|
89
|
+
const result = await db.notification.updateMany({ userId, status: { $in: ["sent", "unread"] } }, { status: "read", updatedAt: Date.now() });
|
|
54
90
|
const updatedNotifications = await db.notification.find({
|
|
55
91
|
userId,
|
|
56
92
|
status: "read",
|
|
@@ -132,6 +168,7 @@ const NotificationsController = (db, wss) => {
|
|
|
132
168
|
};
|
|
133
169
|
return {
|
|
134
170
|
create,
|
|
171
|
+
createBatch,
|
|
135
172
|
getUserNotifications,
|
|
136
173
|
markAsRead,
|
|
137
174
|
registerDevice,
|
|
@@ -200,10 +237,11 @@ const UserDeviceModel = (db, additionalFields = {}) => {
|
|
|
200
237
|
schema.index({ userId: 1, deviceId: 1 }, { unique: true });
|
|
201
238
|
return db.mongoose.model("UserDevice", schema);
|
|
202
239
|
};
|
|
203
|
-
const notificationsRoutes = (app, db, wss, origins, publicPath) => {
|
|
204
|
-
const controller = NotificationsController(db, wss);
|
|
240
|
+
const notificationsRoutes = (app, db, wss, origins, publicPath, notificationService) => {
|
|
241
|
+
const controller = NotificationsController(db, wss, notificationService);
|
|
205
242
|
app.get("/api/notifications/user/:userId", controller.getUserNotifications);
|
|
206
243
|
app.post("/api/notifications", controller.create);
|
|
244
|
+
app.post("/api/notifications/batch", controller.createBatch);
|
|
207
245
|
app.put("/api/notifications/:id/read", controller.markAsRead);
|
|
208
246
|
app.put("/api/notifications/user/:userId/read-all", controller.markAllAsRead);
|
|
209
247
|
app.post("/api/notifications/devices/register", controller.registerDevice);
|
|
@@ -371,7 +409,7 @@ const NotificationService = function(db, wss) {
|
|
|
371
409
|
try {
|
|
372
410
|
const userId = notification.userId.toString();
|
|
373
411
|
const preferences = await db.notificationPreference.find({
|
|
374
|
-
userId
|
|
412
|
+
userId: new ObjectId(userId)
|
|
375
413
|
// notificationType: notification.type
|
|
376
414
|
});
|
|
377
415
|
console.log("userId", userId);
|
|
@@ -391,55 +429,106 @@ const NotificationService = function(db, wss) {
|
|
|
391
429
|
// whatsapp: sendWhatsAppNotification
|
|
392
430
|
};
|
|
393
431
|
const userDevices = await db.userDevice.find({
|
|
394
|
-
userId,
|
|
432
|
+
userId: new ObjectId(userId),
|
|
395
433
|
isActive: true
|
|
396
434
|
});
|
|
435
|
+
console.log("=== CHANNEL SELECTION DEBUG ===");
|
|
436
|
+
console.log("userDevices found:", userDevices.length);
|
|
437
|
+
console.log("userDevices:", userDevices);
|
|
438
|
+
console.log("user.email:", user.email);
|
|
439
|
+
console.log("user.phoneNumber:", user.phoneNumber);
|
|
440
|
+
console.log("preferences.length:", preferences.length);
|
|
397
441
|
let channels = ["web"];
|
|
442
|
+
if (userDevices.length > 0) {
|
|
443
|
+
channels.push("push");
|
|
444
|
+
console.log("Added push channel - devices found");
|
|
445
|
+
} else {
|
|
446
|
+
console.log("No push channel - no devices found");
|
|
447
|
+
}
|
|
398
448
|
if (user.email) {
|
|
399
449
|
channels.push("email");
|
|
450
|
+
console.log("Added email channel");
|
|
400
451
|
}
|
|
401
452
|
if (user.phoneNumber) {
|
|
402
453
|
channels.push("sms");
|
|
454
|
+
console.log("Added SMS channel");
|
|
403
455
|
}
|
|
404
456
|
if (preferences.length > 0) {
|
|
405
457
|
channels = preferences.filter((pref) => pref.isEnabled).map((pref) => pref.channelType);
|
|
458
|
+
console.log("Overridden with user preferences:", channels);
|
|
406
459
|
}
|
|
407
|
-
console.log("
|
|
460
|
+
console.log("=== FINAL CHANNELS ===", channels);
|
|
461
|
+
const channelPromises = [];
|
|
408
462
|
for (const channel of channels) {
|
|
463
|
+
console.log(`=== PREPARING CHANNEL: ${channel} ===`);
|
|
409
464
|
const sendFunc = channelRouters[channel];
|
|
410
|
-
if (sendFunc) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
error
|
|
438
|
-
|
|
439
|
-
})
|
|
465
|
+
if (!sendFunc) {
|
|
466
|
+
channelPromises.push(Promise.resolve({
|
|
467
|
+
channel,
|
|
468
|
+
success: false,
|
|
469
|
+
error: "No send function"
|
|
470
|
+
}));
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (channel === "push") {
|
|
474
|
+
console.log(`Preparing push to ${userDevices.length} devices`);
|
|
475
|
+
for (const device of userDevices) {
|
|
476
|
+
channelPromises.push(
|
|
477
|
+
sendFunc(notification, user, device).then(() => {
|
|
478
|
+
console.log(`Push sent successfully to device ${device.deviceId}`);
|
|
479
|
+
return { channel: "push", deviceId: device.deviceId, success: true };
|
|
480
|
+
}).catch((err) => {
|
|
481
|
+
console.error(`Push failed for device ${device.deviceId}:`, err);
|
|
482
|
+
return { channel: "push", deviceId: device.deviceId, success: false, error: err.message };
|
|
483
|
+
})
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
} else {
|
|
487
|
+
channelPromises.push(
|
|
488
|
+
sendFunc(notification, user).then(() => {
|
|
489
|
+
console.log(`${channel} notification sent successfully`);
|
|
490
|
+
return { channel, success: true };
|
|
491
|
+
}).catch((err) => {
|
|
492
|
+
console.error(`${channel} notification failed:`, err);
|
|
493
|
+
return { channel, success: false, error: err.message };
|
|
494
|
+
})
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
console.log(`=== PROCESSING ${channelPromises.length} PARALLEL OPERATIONS ===`);
|
|
499
|
+
const results = await Promise.allSettled(channelPromises);
|
|
500
|
+
const logs = [];
|
|
501
|
+
const channelSuccessMap = /* @__PURE__ */ new Map();
|
|
502
|
+
results.forEach(({ status, value }) => {
|
|
503
|
+
if (status === "fulfilled" && value) {
|
|
504
|
+
const logEntry = {
|
|
505
|
+
notificationId: notification._id,
|
|
506
|
+
userId: notification.userId,
|
|
507
|
+
channelType: value.channel,
|
|
508
|
+
status: value.success ? "sent" : "failed",
|
|
509
|
+
sentAt: Date.now()
|
|
510
|
+
};
|
|
511
|
+
if (!value.success) {
|
|
512
|
+
logEntry.error = value.error;
|
|
513
|
+
}
|
|
514
|
+
logs.push(logEntry);
|
|
515
|
+
if (value.success) {
|
|
516
|
+
channelSuccessMap.set(value.channel, true);
|
|
440
517
|
}
|
|
441
518
|
}
|
|
519
|
+
});
|
|
520
|
+
if (logs.length > 0) {
|
|
521
|
+
setImmediate(() => db.notificationLog.insertMany(logs).catch(console.error));
|
|
522
|
+
console.log(`Scheduled ${logs.length} logs for batch insertion`);
|
|
442
523
|
}
|
|
524
|
+
const hasSuccessfulSend = channelSuccessMap.size > 0;
|
|
525
|
+
console.log(`=== PROCESSING COMPLETE - Success: ${hasSuccessfulSend} ===`);
|
|
526
|
+
setImmediate(() => {
|
|
527
|
+
db.notification.findByIdAndUpdate(notification._id, {
|
|
528
|
+
status: hasSuccessfulSend ? "sent" : "failed",
|
|
529
|
+
updatedAt: Date.now()
|
|
530
|
+
}).catch(console.error);
|
|
531
|
+
});
|
|
443
532
|
} catch (error) {
|
|
444
533
|
console.error("Error processing notification:", error);
|
|
445
534
|
await db.notification.findByIdAndUpdate(notification._id, {
|
|
@@ -511,14 +600,23 @@ function initializeNotifications(app, db, wss, origins, publicPath) {
|
|
|
511
600
|
db.notificationPreference = NotificationPreferenceModel(db);
|
|
512
601
|
db.notificationLog = NotificationLogModel(db);
|
|
513
602
|
getInstance(db);
|
|
603
|
+
const notificationService = NotificationService(db, wss);
|
|
514
604
|
if (app) {
|
|
515
|
-
notificationsRoutes(app, db, wss);
|
|
605
|
+
notificationsRoutes(app, db, wss, origins, publicPath, notificationService);
|
|
516
606
|
}
|
|
517
|
-
const notificationService = NotificationService(db, wss);
|
|
518
607
|
console.log("[DEBUG] WSS in notification init:", wss);
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
608
|
+
let isProcessing = false;
|
|
609
|
+
setInterval(async () => {
|
|
610
|
+
if (isProcessing) return;
|
|
611
|
+
isProcessing = true;
|
|
612
|
+
try {
|
|
613
|
+
await notificationService.processPendingNotifications();
|
|
614
|
+
} catch (error) {
|
|
615
|
+
console.error("Error in processPendingNotifications:", error);
|
|
616
|
+
} finally {
|
|
617
|
+
isProcessing = false;
|
|
618
|
+
}
|
|
619
|
+
}, 1e4);
|
|
522
620
|
}
|
|
523
621
|
const models = {
|
|
524
622
|
NotificationModel,
|