@ozdao/martyrs 0.2.468 → 0.2.470
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/{Media-DwVcRIAX.mjs → Media-C4Ges_Sd.mjs} +1 -1
- package/dist/{Media-DCGbUujy.js → Media-CR0V1zvB.js} +1 -1
- package/dist/chats.server.js +14 -13
- package/dist/chats.server.mjs +14 -13
- package/dist/globals.server.js +20 -12
- package/dist/globals.server.mjs +20 -12
- package/dist/{main-DEHjtgLs.mjs → main-CTcal9qN.mjs} +900 -884
- package/dist/{main-UVdexuMN.js → main-CsZAG5Wz.js} +5 -5
- 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/SelectMulti/{SelectMulti.vue2.cjs → SelectMulti.vue.cjs} +2 -2
- package/dist/martyrs/src/components/SelectMulti/{SelectMulti.vue2.js.map → SelectMulti.vue.cjs.map} +1 -1
- package/dist/martyrs/src/components/SelectMulti/{SelectMulti.vue2.js → SelectMulti.vue.js} +2 -2
- package/dist/martyrs/src/components/SelectMulti/SelectMulti.vue.js.map +1 -0
- package/dist/martyrs/src/components/Tooltip/{Tooltip.vue.cjs → Tooltip.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Tooltip/Tooltip.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Tooltip/{Tooltip.vue.js → Tooltip.vue2.js} +2 -2
- package/dist/martyrs/src/components/Tooltip/{Tooltip.vue.cjs.map → Tooltip.vue2.js.map} +1 -1
- package/dist/martyrs/src/modules/backoffice/components/partials/Sidebar.vue.cjs +1 -1
- package/dist/martyrs/src/modules/backoffice/components/partials/Sidebar.vue.js +1 -1
- package/dist/martyrs/src/modules/chats/store/chat.store.cjs +47 -16
- package/dist/martyrs/src/modules/chats/store/chat.store.cjs.map +1 -1
- package/dist/martyrs/src/modules/chats/store/chat.store.js +47 -16
- package/dist/martyrs/src/modules/chats/store/chat.store.js.map +1 -1
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.js +1 -1
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.js.map +1 -1
- package/dist/martyrs/src/modules/community/components/pages/Blog.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/pages/Blog.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/community/components/pages/Blog.vue.js +1 -1
- package/dist/martyrs/src/modules/community/components/pages/Blog.vue.js.map +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.cjs +4 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js +4 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js.map +1 -1
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.cjs +3 -3
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js +3 -3
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js.map +1 -1
- package/dist/martyrs/src/modules/constructor/components/elements/VideoPlayer.vue.cjs +1 -1
- package/dist/martyrs/src/modules/constructor/components/elements/VideoPlayer.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/constructor/components/elements/VideoPlayer.vue.js +1 -1
- package/dist/martyrs/src/modules/constructor/components/elements/VideoPlayer.vue.js.map +1 -1
- package/dist/martyrs/src/modules/constructor/components/sections/Constructor.vue.cjs +9 -9
- package/dist/martyrs/src/modules/constructor/components/sections/Constructor.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/constructor/components/sections/Constructor.vue.js +9 -9
- package/dist/martyrs/src/modules/constructor/components/sections/Constructor.vue.js.map +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.cjs +2 -2
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js +2 -2
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js.map +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 +0 -9
- package/dist/martyrs/src/modules/globals/globals.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/globals.client.js +0 -9
- package/dist/martyrs/src/modules/globals/globals.client.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.cjs +40 -97
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.js +40 -97
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +1 -1
- package/dist/martyrs/src/modules/icons/skeletons/SkeletonBlogpost.vue.cjs +1 -1
- package/dist/martyrs/src/modules/icons/skeletons/SkeletonBlogpost.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/icons/skeletons/SkeletonBlogpost.vue.js +1 -1
- package/dist/martyrs/src/modules/icons/skeletons/SkeletonBlogpost.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.cjs +35 -9
- package/dist/martyrs/src/modules/notifications/notifications.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.js +35 -9
- package/dist/martyrs/src/modules/notifications/notifications.client.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/pages/OrderCreate.vue.cjs +7 -7
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js +8 -8
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.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/pages/OrganizationBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.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/CardPosition.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/blocks/CardPosition.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/EditLeftover.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs +6 -5
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +6 -5
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js.map +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/RentsEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/RentsEdit.vue.js +1 -1
- package/dist/martyrs.cjs.js +1 -1
- package/dist/martyrs.css +1 -1
- package/dist/martyrs.es.js +1 -1
- package/dist/notifications.server.js +69 -13
- package/dist/notifications.server.mjs +69 -13
- package/dist/orders.server.js +1 -0
- package/dist/orders.server.mjs +1 -0
- package/package.json +1 -1
- package/src/components/Shader/Shader.vue +44 -25
- package/src/modules/chats/routes/chats.routes.js +21 -17
- package/src/modules/chats/store/chat.store.js +55 -28
- package/src/modules/community/components/blocks/CardBlogpost.vue +1 -1
- package/src/modules/community/components/pages/Blog.vue +1 -1
- package/src/modules/community/components/pages/BlogPost.vue +1 -0
- package/src/modules/community/components/pages/CreateBlogPost.vue +3 -3
- package/src/modules/constructor/components/elements/VideoPlayer.vue +1 -1
- package/src/modules/constructor/components/sections/Constructor.vue +9 -9
- package/src/modules/events/components/pages/EditEvent.vue +1 -1
- package/src/modules/globals/controllers/classes/globals.websocket.js +29 -21
- package/src/modules/globals/globals.client.js +0 -12
- package/src/modules/globals/views/classes/globals.websocket.js +46 -146
- package/src/modules/icons/skeletons/SkeletonBlogpost.vue +2 -2
- package/src/modules/notifications/controllers/notifications.controller.js +2 -2
- package/src/modules/notifications/notifications.client.js +57 -19
- package/src/modules/notifications/notifications.server.js +3 -1
- package/src/modules/notifications/routes/notifications.routes.js +2 -2
- package/src/modules/notifications/services/notification.service.js +34 -15
- package/src/modules/notifications/services/web-push.service.js +7 -6
- package/src/modules/orders/components/pages/OrderCreate.vue +3 -4
- package/src/modules/orders/controllers/orders.controller.js +2 -0
- package/src/modules/products/components/pages/Product.vue +7 -6
- package/dist/martyrs/src/components/SelectMulti/SelectMulti.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Tooltip/Tooltip.vue.js.map +0 -1
- package/src/modules/notifications/notifications2.client.js +0 -256
- package/src/modules/notifications/services/websocket.service.js +0 -100
package/dist/martyrs.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as o, t, b as d, c as r, u as l, v as i, w as p, d as u, x as n, e as m, y as M, F as S, z as c, f as F, A as g, L as h, g as b, M as k, E as x, n as B, o as C, h as T, i as U, S as f, j as w, B as D, C as E, k as I, D as L, l as P, q, p as y, U as A, r as j, s as v, m as z } from "./main-
|
|
1
|
+
import { a as o, t, b as d, c as r, u as l, v as i, w as p, d as u, x as n, e as m, y as M, F as S, z as c, f as F, A as g, L as h, g as b, M as k, E as x, n as B, o as C, h as T, i as U, S as f, j as w, B as D, C as E, k as I, D as L, l as P, q, p as y, U as A, r as j, s as v, m as z } from "./main-CTcal9qN.mjs";
|
|
2
2
|
import "vue";
|
|
3
3
|
export {
|
|
4
4
|
o as Address,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const _commonjsHelpers = require("./_commonjsHelpers-DHfMLFPC.js");
|
|
3
|
+
const require$$0$4 = require("mongoose");
|
|
3
4
|
const require$$0 = require("apn");
|
|
4
5
|
const require$$0$1 = require("firebase-admin");
|
|
5
6
|
const require$$0$2 = require("path");
|
|
7
|
+
const require$$0$3 = require("web-push");
|
|
6
8
|
const mailing = require("./mailing-D4kWlk3_.js");
|
|
7
9
|
require("dotenv");
|
|
8
10
|
require("nodemailer");
|
|
@@ -123,6 +125,44 @@ function requireFcm_service() {
|
|
|
123
125
|
fcm_service = FcmService;
|
|
124
126
|
return fcm_service;
|
|
125
127
|
}
|
|
128
|
+
var webPush_service;
|
|
129
|
+
var hasRequiredWebPush_service;
|
|
130
|
+
function requireWebPush_service() {
|
|
131
|
+
if (hasRequiredWebPush_service) return webPush_service;
|
|
132
|
+
hasRequiredWebPush_service = 1;
|
|
133
|
+
const webpush = require$$0$3;
|
|
134
|
+
webpush.setVapidDetails(
|
|
135
|
+
`mailto:${process.env.VAPID_EMAIL}`,
|
|
136
|
+
process.env.VAPID_PUBLIC_KEY,
|
|
137
|
+
process.env.VAPID_PRIVATE_KEY
|
|
138
|
+
);
|
|
139
|
+
const WebPushService = {
|
|
140
|
+
send: async ({ token, title, body, data = {} }) => {
|
|
141
|
+
try {
|
|
142
|
+
const subscription = JSON.parse(token);
|
|
143
|
+
console.log("title is", title);
|
|
144
|
+
console.log("body is", body);
|
|
145
|
+
console.log("data is", data);
|
|
146
|
+
const payload = JSON.stringify({
|
|
147
|
+
title,
|
|
148
|
+
body,
|
|
149
|
+
icon: process.env.NOTIFICATION_ICON_URL || "/favicon.ico",
|
|
150
|
+
badge: process.env.NOTIFICATION_BADGE_URL || "/favicon.ico",
|
|
151
|
+
data
|
|
152
|
+
});
|
|
153
|
+
console.log("payload is", payload);
|
|
154
|
+
const result = await webpush.sendNotification(subscription, payload);
|
|
155
|
+
console.log("web push is", result);
|
|
156
|
+
return { success: true, statusCode: result.statusCode };
|
|
157
|
+
} catch (error) {
|
|
158
|
+
console.error("Web Push service error:", error);
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
webPush_service = WebPushService;
|
|
164
|
+
return webPush_service;
|
|
165
|
+
}
|
|
126
166
|
var email_service;
|
|
127
167
|
var hasRequiredEmail_service;
|
|
128
168
|
function requireEmail_service() {
|
|
@@ -175,15 +215,23 @@ var hasRequiredNotification_service;
|
|
|
175
215
|
function requireNotification_service() {
|
|
176
216
|
if (hasRequiredNotification_service) return notification_service;
|
|
177
217
|
hasRequiredNotification_service = 1;
|
|
178
|
-
const
|
|
218
|
+
const ObjectId = require$$0$4.Types.ObjectId;
|
|
219
|
+
notification_service = function(db, wss) {
|
|
220
|
+
wss.registerModule("notification", async (ws, msg) => {
|
|
221
|
+
console.log("[WebSocket][notification] msg:", msg);
|
|
222
|
+
});
|
|
179
223
|
const processNotification = async (notification) => {
|
|
180
224
|
try {
|
|
181
|
-
const userId = notification.userId;
|
|
225
|
+
const userId = notification.userId.toString();
|
|
182
226
|
const preferences = await db.notificationPreference.find({
|
|
183
|
-
userId
|
|
184
|
-
notificationType: notification.type
|
|
227
|
+
userId
|
|
228
|
+
// notificationType: notification.type
|
|
185
229
|
});
|
|
186
|
-
|
|
230
|
+
console.log("userId", userId);
|
|
231
|
+
console.log("preferences", preferences);
|
|
232
|
+
console.log("notificationType", notification.type);
|
|
233
|
+
console.log("notification", notification);
|
|
234
|
+
const user = await db.mongoose.model("User").findById(new ObjectId(userId));
|
|
187
235
|
if (!user) {
|
|
188
236
|
throw new Error(`User not found: ${userId}`);
|
|
189
237
|
}
|
|
@@ -209,6 +257,7 @@ function requireNotification_service() {
|
|
|
209
257
|
if (preferences.length > 0) {
|
|
210
258
|
channels = preferences.filter((pref) => pref.isEnabled).map((pref) => pref.channelType);
|
|
211
259
|
}
|
|
260
|
+
console.log("channels", channels);
|
|
212
261
|
for (const channel of channels) {
|
|
213
262
|
const sendFunc = channelRouters[channel];
|
|
214
263
|
if (sendFunc) {
|
|
@@ -253,10 +302,14 @@ function requireNotification_service() {
|
|
|
253
302
|
}
|
|
254
303
|
};
|
|
255
304
|
const sendWebNotification = async (notification, user) => {
|
|
256
|
-
|
|
305
|
+
console.log(`[WebSocket][notification] sending to user ${user._id}`);
|
|
306
|
+
const result = await wss.sendToUserInModule("notification", user._id, {
|
|
257
307
|
type: "notification",
|
|
258
308
|
data: notification
|
|
259
309
|
});
|
|
310
|
+
if (!result) {
|
|
311
|
+
console.log(`Failed to send web notification to user ${user._id}`);
|
|
312
|
+
}
|
|
260
313
|
};
|
|
261
314
|
const sendPushNotification = async (notification, user, device) => {
|
|
262
315
|
const pushService = getPushServiceByDeviceType(device.deviceType);
|
|
@@ -272,7 +325,9 @@ function requireNotification_service() {
|
|
|
272
325
|
return requireApns_service();
|
|
273
326
|
} else if (deviceType === "android") {
|
|
274
327
|
return requireFcm_service();
|
|
275
|
-
} else
|
|
328
|
+
} else {
|
|
329
|
+
return requireWebPush_service();
|
|
330
|
+
}
|
|
276
331
|
};
|
|
277
332
|
const sendEmailNotification = async (notification, user) => {
|
|
278
333
|
const emailService = requireEmail_service();
|
|
@@ -304,7 +359,6 @@ function requireNotification_service() {
|
|
|
304
359
|
processPendingNotifications
|
|
305
360
|
};
|
|
306
361
|
};
|
|
307
|
-
notification_service = NotificationService;
|
|
308
362
|
return notification_service;
|
|
309
363
|
}
|
|
310
364
|
var notifications_controller;
|
|
@@ -312,11 +366,11 @@ var hasRequiredNotifications_controller;
|
|
|
312
366
|
function requireNotifications_controller() {
|
|
313
367
|
if (hasRequiredNotifications_controller) return notifications_controller;
|
|
314
368
|
hasRequiredNotifications_controller = 1;
|
|
315
|
-
const NotificationsController = (db) => {
|
|
369
|
+
const NotificationsController = (db, wss) => {
|
|
316
370
|
const create = async (req, res) => {
|
|
317
371
|
try {
|
|
318
372
|
const notification = await db.notification.create(req.body);
|
|
319
|
-
const notificationService = requireNotification_service()(db);
|
|
373
|
+
const notificationService = requireNotification_service()(db, wss);
|
|
320
374
|
notificationService.processNotification(notification);
|
|
321
375
|
return res.status(201).json(notification);
|
|
322
376
|
} catch (err) {
|
|
@@ -429,8 +483,8 @@ var hasRequiredNotifications_routes;
|
|
|
429
483
|
function requireNotifications_routes() {
|
|
430
484
|
if (hasRequiredNotifications_routes) return notifications_routes;
|
|
431
485
|
hasRequiredNotifications_routes = 1;
|
|
432
|
-
const notificationsRoutes = (app, db, origins, publicPath) => {
|
|
433
|
-
const controller = requireNotifications_controller()(db);
|
|
486
|
+
const notificationsRoutes = (app, db, wss, origins, publicPath) => {
|
|
487
|
+
const controller = requireNotifications_controller()(db, wss);
|
|
434
488
|
app.get("/api/notifications/user/:userId", controller.getUserNotifications);
|
|
435
489
|
app.post("/api/notifications", controller.create);
|
|
436
490
|
app.put("/api/notifications/:id/read", controller.markAsRead);
|
|
@@ -535,15 +589,17 @@ function requireNotifications_server() {
|
|
|
535
589
|
const NotificationService = requireNotification_service();
|
|
536
590
|
const { getInstance } = globals_abac.requireGlobals_abac();
|
|
537
591
|
function initializeNotifications(app, db, wss, origins, publicPath) {
|
|
592
|
+
console.log("wss init is", wss);
|
|
538
593
|
db.notification = NotificationModel(db);
|
|
539
594
|
db.userDevice = UserDeviceModel(db);
|
|
540
595
|
db.notificationPreference = NotificationPreferenceModel(db);
|
|
541
596
|
db.notificationLog = NotificationLogModel(db);
|
|
542
597
|
getInstance(db);
|
|
543
598
|
if (app) {
|
|
544
|
-
notificationsRoutes(app, db, origins, publicPath);
|
|
599
|
+
notificationsRoutes(app, db, wss, origins, publicPath);
|
|
545
600
|
}
|
|
546
601
|
const notificationService = NotificationService(db, wss);
|
|
602
|
+
console.log("[DEBUG] WSS in notification init:", wss);
|
|
547
603
|
setInterval(() => {
|
|
548
604
|
notificationService.processPendingNotifications();
|
|
549
605
|
}, 6e4);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-CUmg6egw.mjs";
|
|
2
|
+
import require$$0$4 from "mongoose";
|
|
2
3
|
import require$$0 from "apn";
|
|
3
4
|
import require$$0$1 from "firebase-admin";
|
|
4
5
|
import require$$0$2 from "path";
|
|
6
|
+
import require$$0$3 from "web-push";
|
|
5
7
|
import { r as requireMailing } from "./mailing-DvCT5ijo.mjs";
|
|
6
8
|
import "dotenv";
|
|
7
9
|
import "nodemailer";
|
|
@@ -122,6 +124,44 @@ function requireFcm_service() {
|
|
|
122
124
|
fcm_service = FcmService;
|
|
123
125
|
return fcm_service;
|
|
124
126
|
}
|
|
127
|
+
var webPush_service;
|
|
128
|
+
var hasRequiredWebPush_service;
|
|
129
|
+
function requireWebPush_service() {
|
|
130
|
+
if (hasRequiredWebPush_service) return webPush_service;
|
|
131
|
+
hasRequiredWebPush_service = 1;
|
|
132
|
+
const webpush = require$$0$3;
|
|
133
|
+
webpush.setVapidDetails(
|
|
134
|
+
`mailto:${process.env.VAPID_EMAIL}`,
|
|
135
|
+
process.env.VAPID_PUBLIC_KEY,
|
|
136
|
+
process.env.VAPID_PRIVATE_KEY
|
|
137
|
+
);
|
|
138
|
+
const WebPushService = {
|
|
139
|
+
send: async ({ token, title, body, data = {} }) => {
|
|
140
|
+
try {
|
|
141
|
+
const subscription = JSON.parse(token);
|
|
142
|
+
console.log("title is", title);
|
|
143
|
+
console.log("body is", body);
|
|
144
|
+
console.log("data is", data);
|
|
145
|
+
const payload = JSON.stringify({
|
|
146
|
+
title,
|
|
147
|
+
body,
|
|
148
|
+
icon: process.env.NOTIFICATION_ICON_URL || "/favicon.ico",
|
|
149
|
+
badge: process.env.NOTIFICATION_BADGE_URL || "/favicon.ico",
|
|
150
|
+
data
|
|
151
|
+
});
|
|
152
|
+
console.log("payload is", payload);
|
|
153
|
+
const result = await webpush.sendNotification(subscription, payload);
|
|
154
|
+
console.log("web push is", result);
|
|
155
|
+
return { success: true, statusCode: result.statusCode };
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.error("Web Push service error:", error);
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
webPush_service = WebPushService;
|
|
163
|
+
return webPush_service;
|
|
164
|
+
}
|
|
125
165
|
var email_service;
|
|
126
166
|
var hasRequiredEmail_service;
|
|
127
167
|
function requireEmail_service() {
|
|
@@ -174,15 +214,23 @@ var hasRequiredNotification_service;
|
|
|
174
214
|
function requireNotification_service() {
|
|
175
215
|
if (hasRequiredNotification_service) return notification_service;
|
|
176
216
|
hasRequiredNotification_service = 1;
|
|
177
|
-
const
|
|
217
|
+
const ObjectId = require$$0$4.Types.ObjectId;
|
|
218
|
+
notification_service = function(db, wss) {
|
|
219
|
+
wss.registerModule("notification", async (ws, msg) => {
|
|
220
|
+
console.log("[WebSocket][notification] msg:", msg);
|
|
221
|
+
});
|
|
178
222
|
const processNotification = async (notification) => {
|
|
179
223
|
try {
|
|
180
|
-
const userId = notification.userId;
|
|
224
|
+
const userId = notification.userId.toString();
|
|
181
225
|
const preferences = await db.notificationPreference.find({
|
|
182
|
-
userId
|
|
183
|
-
notificationType: notification.type
|
|
226
|
+
userId
|
|
227
|
+
// notificationType: notification.type
|
|
184
228
|
});
|
|
185
|
-
|
|
229
|
+
console.log("userId", userId);
|
|
230
|
+
console.log("preferences", preferences);
|
|
231
|
+
console.log("notificationType", notification.type);
|
|
232
|
+
console.log("notification", notification);
|
|
233
|
+
const user = await db.mongoose.model("User").findById(new ObjectId(userId));
|
|
186
234
|
if (!user) {
|
|
187
235
|
throw new Error(`User not found: ${userId}`);
|
|
188
236
|
}
|
|
@@ -208,6 +256,7 @@ function requireNotification_service() {
|
|
|
208
256
|
if (preferences.length > 0) {
|
|
209
257
|
channels = preferences.filter((pref) => pref.isEnabled).map((pref) => pref.channelType);
|
|
210
258
|
}
|
|
259
|
+
console.log("channels", channels);
|
|
211
260
|
for (const channel of channels) {
|
|
212
261
|
const sendFunc = channelRouters[channel];
|
|
213
262
|
if (sendFunc) {
|
|
@@ -252,10 +301,14 @@ function requireNotification_service() {
|
|
|
252
301
|
}
|
|
253
302
|
};
|
|
254
303
|
const sendWebNotification = async (notification, user) => {
|
|
255
|
-
|
|
304
|
+
console.log(`[WebSocket][notification] sending to user ${user._id}`);
|
|
305
|
+
const result = await wss.sendToUserInModule("notification", user._id, {
|
|
256
306
|
type: "notification",
|
|
257
307
|
data: notification
|
|
258
308
|
});
|
|
309
|
+
if (!result) {
|
|
310
|
+
console.log(`Failed to send web notification to user ${user._id}`);
|
|
311
|
+
}
|
|
259
312
|
};
|
|
260
313
|
const sendPushNotification = async (notification, user, device) => {
|
|
261
314
|
const pushService = getPushServiceByDeviceType(device.deviceType);
|
|
@@ -271,7 +324,9 @@ function requireNotification_service() {
|
|
|
271
324
|
return requireApns_service();
|
|
272
325
|
} else if (deviceType === "android") {
|
|
273
326
|
return requireFcm_service();
|
|
274
|
-
} else
|
|
327
|
+
} else {
|
|
328
|
+
return requireWebPush_service();
|
|
329
|
+
}
|
|
275
330
|
};
|
|
276
331
|
const sendEmailNotification = async (notification, user) => {
|
|
277
332
|
const emailService = requireEmail_service();
|
|
@@ -303,7 +358,6 @@ function requireNotification_service() {
|
|
|
303
358
|
processPendingNotifications
|
|
304
359
|
};
|
|
305
360
|
};
|
|
306
|
-
notification_service = NotificationService;
|
|
307
361
|
return notification_service;
|
|
308
362
|
}
|
|
309
363
|
var notifications_controller;
|
|
@@ -311,11 +365,11 @@ var hasRequiredNotifications_controller;
|
|
|
311
365
|
function requireNotifications_controller() {
|
|
312
366
|
if (hasRequiredNotifications_controller) return notifications_controller;
|
|
313
367
|
hasRequiredNotifications_controller = 1;
|
|
314
|
-
const NotificationsController = (db) => {
|
|
368
|
+
const NotificationsController = (db, wss) => {
|
|
315
369
|
const create = async (req, res) => {
|
|
316
370
|
try {
|
|
317
371
|
const notification = await db.notification.create(req.body);
|
|
318
|
-
const notificationService = requireNotification_service()(db);
|
|
372
|
+
const notificationService = requireNotification_service()(db, wss);
|
|
319
373
|
notificationService.processNotification(notification);
|
|
320
374
|
return res.status(201).json(notification);
|
|
321
375
|
} catch (err) {
|
|
@@ -428,8 +482,8 @@ var hasRequiredNotifications_routes;
|
|
|
428
482
|
function requireNotifications_routes() {
|
|
429
483
|
if (hasRequiredNotifications_routes) return notifications_routes;
|
|
430
484
|
hasRequiredNotifications_routes = 1;
|
|
431
|
-
const notificationsRoutes = (app, db, origins, publicPath) => {
|
|
432
|
-
const controller = requireNotifications_controller()(db);
|
|
485
|
+
const notificationsRoutes = (app, db, wss, origins, publicPath) => {
|
|
486
|
+
const controller = requireNotifications_controller()(db, wss);
|
|
433
487
|
app.get("/api/notifications/user/:userId", controller.getUserNotifications);
|
|
434
488
|
app.post("/api/notifications", controller.create);
|
|
435
489
|
app.put("/api/notifications/:id/read", controller.markAsRead);
|
|
@@ -534,15 +588,17 @@ function requireNotifications_server() {
|
|
|
534
588
|
const NotificationService = requireNotification_service();
|
|
535
589
|
const { getInstance } = requireGlobals_abac();
|
|
536
590
|
function initializeNotifications(app, db, wss, origins, publicPath) {
|
|
591
|
+
console.log("wss init is", wss);
|
|
537
592
|
db.notification = NotificationModel(db);
|
|
538
593
|
db.userDevice = UserDeviceModel(db);
|
|
539
594
|
db.notificationPreference = NotificationPreferenceModel(db);
|
|
540
595
|
db.notificationLog = NotificationLogModel(db);
|
|
541
596
|
getInstance(db);
|
|
542
597
|
if (app) {
|
|
543
|
-
notificationsRoutes(app, db, origins, publicPath);
|
|
598
|
+
notificationsRoutes(app, db, wss, origins, publicPath);
|
|
544
599
|
}
|
|
545
600
|
const notificationService = NotificationService(db, wss);
|
|
601
|
+
console.log("[DEBUG] WSS in notification init:", wss);
|
|
546
602
|
setInterval(() => {
|
|
547
603
|
notificationService.processPendingNotifications();
|
|
548
604
|
}, 6e4);
|
package/dist/orders.server.js
CHANGED
|
@@ -513,6 +513,7 @@ ${formatPositions(order.positions)}
|
|
|
513
513
|
userId: order.creator.target
|
|
514
514
|
// Assuming creator.target holds the user ID
|
|
515
515
|
};
|
|
516
|
+
console.log("notifiocatio data", JSON.stringify(notificationData));
|
|
516
517
|
const notificationResponse = await fetch(`${process.env.API_URL || ""}/api/notifications`, {
|
|
517
518
|
method: "POST",
|
|
518
519
|
headers: {
|
package/dist/orders.server.mjs
CHANGED
|
@@ -512,6 +512,7 @@ ${formatPositions(order.positions)}
|
|
|
512
512
|
userId: order.creator.target
|
|
513
513
|
// Assuming creator.target holds the user ID
|
|
514
514
|
};
|
|
515
|
+
console.log("notifiocatio data", JSON.stringify(notificationData));
|
|
515
516
|
const notificationResponse = await fetch(`${process.env.API_URL || ""}/api/notifications`, {
|
|
516
517
|
method: "POST",
|
|
517
518
|
headers: {
|
package/package.json
CHANGED
|
@@ -1,58 +1,79 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<canvas ref="refCanvas" />
|
|
3
3
|
</template>
|
|
4
|
-
|
|
5
4
|
<script setup>
|
|
6
|
-
import { onMounted, ref } from 'vue'
|
|
5
|
+
import { onMounted, ref, watch } from 'vue'
|
|
7
6
|
|
|
8
7
|
const props = defineProps({
|
|
9
8
|
shader: {
|
|
10
9
|
type: String,
|
|
11
10
|
required: true
|
|
11
|
+
},
|
|
12
|
+
theme: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: 'light' // или любое другое значение по умолчанию
|
|
12
15
|
}
|
|
13
16
|
})
|
|
14
17
|
|
|
15
18
|
const refCanvas = ref(null)
|
|
19
|
+
let gl = null
|
|
20
|
+
let shaderProgram = null
|
|
21
|
+
let themeUniformLocation = null
|
|
22
|
+
|
|
23
|
+
// Функция для обновления uniform-переменных в шейдере
|
|
24
|
+
const updateUniforms = () => {
|
|
25
|
+
if (!gl || !shaderProgram) return
|
|
26
|
+
|
|
27
|
+
// Получаем location для переменной iTheme
|
|
28
|
+
if (!themeUniformLocation) {
|
|
29
|
+
themeUniformLocation = gl.getUniformLocation(shaderProgram, 'iTheme')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Устанавливаем значение: 0.0 для темной темы, 1.0 для светлой
|
|
33
|
+
const themeValue = props.theme === 'light' ? 1.0 : 0.0
|
|
34
|
+
gl.uniform1f(themeUniformLocation, themeValue)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Следим за изменениями темы
|
|
38
|
+
watch(() => props.theme, () => {
|
|
39
|
+
updateUniforms()
|
|
40
|
+
}, { immediate: true })
|
|
16
41
|
|
|
17
42
|
onMounted(() => {
|
|
18
43
|
const canvas = refCanvas.value
|
|
19
|
-
|
|
20
|
-
|
|
44
|
+
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl')
|
|
45
|
+
|
|
21
46
|
const vsSource = `
|
|
22
47
|
attribute vec4 aVertexPosition;
|
|
23
48
|
void main() {
|
|
24
49
|
gl_Position = aVertexPosition;
|
|
25
50
|
}
|
|
26
51
|
`
|
|
27
|
-
|
|
28
52
|
const fsSource = props.shader
|
|
29
|
-
|
|
53
|
+
|
|
30
54
|
function compileShader(gl, type, source) {
|
|
31
55
|
const shader = gl.createShader(type)
|
|
32
56
|
gl.shaderSource(shader, source)
|
|
33
57
|
gl.compileShader(shader)
|
|
34
|
-
|
|
35
58
|
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
36
59
|
alert('An error occurred compiling the shaders: ' + gl.getShaderInfoLog(shader))
|
|
37
60
|
gl.deleteShader(shader)
|
|
38
61
|
return null
|
|
39
62
|
}
|
|
40
|
-
|
|
41
63
|
return shader
|
|
42
64
|
}
|
|
43
|
-
|
|
65
|
+
|
|
44
66
|
const vertexShader = compileShader(gl, gl.VERTEX_SHADER, vsSource)
|
|
45
67
|
const fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, fsSource)
|
|
46
|
-
|
|
47
|
-
const shaderProgram = gl.createProgram()
|
|
68
|
+
shaderProgram = gl.createProgram()
|
|
48
69
|
gl.attachShader(shaderProgram, vertexShader)
|
|
49
70
|
gl.attachShader(shaderProgram, fragmentShader)
|
|
50
71
|
gl.linkProgram(shaderProgram)
|
|
51
|
-
|
|
72
|
+
|
|
52
73
|
if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
|
|
53
74
|
alert('Unable to initialize the shader program: ' + gl.getProgramInfoLog(shaderProgram))
|
|
54
75
|
}
|
|
55
|
-
|
|
76
|
+
|
|
56
77
|
function resizeCanvasToDisplaySize(canvas) {
|
|
57
78
|
const width = canvas.clientWidth * window.devicePixelRatio
|
|
58
79
|
const height = canvas.clientHeight * window.devicePixelRatio
|
|
@@ -63,51 +84,49 @@ onMounted(() => {
|
|
|
63
84
|
}
|
|
64
85
|
return false
|
|
65
86
|
}
|
|
66
|
-
|
|
87
|
+
|
|
67
88
|
function render() {
|
|
68
89
|
if (resizeCanvasToDisplaySize(gl.canvas)) {
|
|
69
90
|
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height)
|
|
70
91
|
}
|
|
71
|
-
|
|
92
|
+
|
|
72
93
|
gl.clearColor(0.0, 0.0, 0.0, 1.0)
|
|
73
94
|
gl.clearDepth(1.0)
|
|
74
95
|
gl.enable(gl.DEPTH_TEST)
|
|
75
96
|
gl.depthFunc(gl.LEQUAL)
|
|
76
|
-
|
|
77
97
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
|
|
78
98
|
gl.useProgram(shaderProgram)
|
|
79
|
-
|
|
99
|
+
|
|
80
100
|
const positionBuffer = gl.createBuffer()
|
|
81
101
|
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)
|
|
82
|
-
|
|
83
102
|
const positions = [
|
|
84
103
|
-1.0, 1.0,
|
|
85
104
|
1.0, 1.0,
|
|
86
105
|
-1.0, -1.0,
|
|
87
106
|
1.0, -1.0,
|
|
88
107
|
]
|
|
89
|
-
|
|
90
108
|
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW)
|
|
91
|
-
|
|
109
|
+
|
|
92
110
|
const vertexPosition = gl.getAttribLocation(shaderProgram, 'aVertexPosition')
|
|
93
111
|
gl.vertexAttribPointer(vertexPosition, 2, gl.FLOAT, false, 0, 0)
|
|
94
112
|
gl.enableVertexAttribArray(vertexPosition)
|
|
95
|
-
|
|
113
|
+
|
|
96
114
|
const timeUniformLocation = gl.getUniformLocation(shaderProgram, 'iTime')
|
|
97
115
|
const resolutionUniformLocation = gl.getUniformLocation(shaderProgram, 'iResolution')
|
|
98
116
|
|
|
99
117
|
gl.uniform1f(timeUniformLocation, performance.now() / 3000.0)
|
|
100
118
|
gl.uniform2f(resolutionUniformLocation, gl.canvas.width, gl.canvas.height)
|
|
101
|
-
|
|
119
|
+
|
|
120
|
+
// Обновляем uniform для темы
|
|
121
|
+
updateUniforms()
|
|
122
|
+
|
|
102
123
|
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4)
|
|
103
|
-
|
|
104
124
|
requestAnimationFrame(render)
|
|
105
125
|
}
|
|
106
|
-
|
|
126
|
+
|
|
107
127
|
requestAnimationFrame(render)
|
|
108
128
|
})
|
|
109
129
|
</script>
|
|
110
|
-
|
|
111
130
|
<style scoped>
|
|
112
131
|
canvas {
|
|
113
132
|
width: 100%;
|
|
@@ -2,27 +2,39 @@
|
|
|
2
2
|
const controllerFactory = require('../controllers/chats.controller.js');
|
|
3
3
|
// Middlewares
|
|
4
4
|
const middlewareFactory = require('@martyrs/src/modules/auth/controllers/middlewares');
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
module.exports = function(app, db, wss) {
|
|
7
7
|
const controller = controllerFactory(db);
|
|
8
|
-
|
|
9
8
|
const { verifySignUp, verifyUser } = middlewareFactory(db);
|
|
10
9
|
|
|
10
|
+
// WebSocket-обработчик для модуля "chat"
|
|
11
11
|
wss.registerModule('chat', async (ws, msg) => {
|
|
12
12
|
if (msg.type === 'joinChat') {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if (!msg.chatId) return;
|
|
14
|
+
// Вешаем chatId на сокет — позволяет фильтровать клиентов
|
|
15
|
+
if (!ws.activeChats) ws.activeChats = new Set();
|
|
16
|
+
ws.activeChats.add(msg.chatId);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (msg.type === 'message') {
|
|
15
20
|
const savedMessage = await controller.saveMessage(msg);
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
);
|
|
22
|
+
// Отправить сообщение всем в этом чате
|
|
23
|
+
wss.broadcastToModuleWithFilter('chat', (client) => {
|
|
24
|
+
return client.activeChats?.has(msg.chatId);
|
|
25
|
+
}, savedMessage);
|
|
21
26
|
}
|
|
22
27
|
});
|
|
23
28
|
|
|
29
|
+
// REST API: получить историю сообщений
|
|
30
|
+
app.get('/messages/:chatId', async (req, res) => {
|
|
31
|
+
const { chatId } = req.params;
|
|
32
|
+
const messages = await controller.getMessages(chatId);
|
|
33
|
+
res.json(messages);
|
|
34
|
+
});
|
|
24
35
|
|
|
25
|
-
|
|
36
|
+
// CORS-заголовки
|
|
37
|
+
app.use((req, res, next) => {
|
|
26
38
|
res.header(
|
|
27
39
|
"Access-Control-Allow-Headers",
|
|
28
40
|
"Access-Control-Allow-Origin: *",
|
|
@@ -30,12 +42,4 @@ module.exports = function(app, db, wss) {
|
|
|
30
42
|
);
|
|
31
43
|
next();
|
|
32
44
|
});
|
|
33
|
-
|
|
34
|
-
// REST API для получения истории сообщений
|
|
35
|
-
app.get('/messages/:chatId', async (req, res) => {
|
|
36
|
-
const { chatId } = req.params;
|
|
37
|
-
const messages = await controller.getMessages(chatId);
|
|
38
|
-
res.json(messages);
|
|
39
|
-
});
|
|
40
45
|
};
|
|
41
|
-
|