@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
|
@@ -8,65 +8,92 @@ const state = reactive({
|
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
const methods = {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Подключение к глобальному WebSocket и подписка на чат
|
|
13
|
+
* @param {String} userId
|
|
14
|
+
*/
|
|
15
|
+
async connectWebSocket(userId) {
|
|
13
16
|
try {
|
|
14
|
-
console.log('
|
|
15
|
-
await globalWebSocket.connect(
|
|
17
|
+
console.log('[Chat] Connecting to WebSocket with userId:', userId);
|
|
18
|
+
await globalWebSocket.connect(userId);
|
|
19
|
+
await globalWebSocket.subscribeModule('chat'); // 👈 Подписка на модуль чата
|
|
16
20
|
|
|
17
|
-
//
|
|
21
|
+
// Очистка старых листенеров
|
|
18
22
|
globalWebSocket.removeModuleListeners('chat');
|
|
19
23
|
|
|
20
|
-
//
|
|
21
|
-
|
|
24
|
+
// Добавляем обработчик входящих сообщений
|
|
25
|
+
globalWebSocket.addEventListener('message', (data) => {
|
|
22
26
|
if (data.chatId === state.currentChatId) {
|
|
23
27
|
state.messages.push(data);
|
|
24
28
|
}
|
|
25
29
|
}, { module: 'chat' });
|
|
26
30
|
|
|
27
|
-
return globalWebSocket;
|
|
28
31
|
} catch (error) {
|
|
29
|
-
console.error('
|
|
32
|
+
console.error('[Chat] WebSocket connection failed:', error);
|
|
30
33
|
throw error;
|
|
31
34
|
}
|
|
32
35
|
},
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
async addMessage(message) {
|
|
40
|
-
await globalWebSocket.send(message);
|
|
41
|
-
},
|
|
42
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Установка текущего активного чата и загрузка сообщений
|
|
39
|
+
* @param {String} chatId
|
|
40
|
+
*/
|
|
43
41
|
async setCurrentChat(chatId) {
|
|
44
42
|
state.currentChatId = chatId;
|
|
45
|
-
state.messages = [];
|
|
43
|
+
state.messages = [];
|
|
46
44
|
|
|
47
|
-
//
|
|
45
|
+
// Отправляем joinChat через WebSocket
|
|
48
46
|
globalWebSocket.send({ type: 'joinChat', module: 'chat', chatId });
|
|
49
47
|
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
// Загружаем историю сообщений
|
|
49
|
+
try {
|
|
50
|
+
const response = await fetch(`/messages/${chatId}`);
|
|
51
|
+
const messages = await response.json();
|
|
52
|
+
methods.setMessages(messages);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.error('[Chat] Failed to fetch messages:', err);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Установка сообщений
|
|
60
|
+
* @param {Array} messages
|
|
61
|
+
*/
|
|
62
|
+
setMessages(messages) {
|
|
63
|
+
state.messages = messages;
|
|
64
|
+
},
|
|
53
65
|
|
|
54
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Отправка сообщения через WebSocket
|
|
68
|
+
* @param {Object} message
|
|
69
|
+
*/
|
|
70
|
+
async addMessage(message) {
|
|
71
|
+
await globalWebSocket.send({
|
|
72
|
+
...message,
|
|
73
|
+
module: 'chat',
|
|
74
|
+
type: 'message',
|
|
75
|
+
chatId: state.currentChatId
|
|
76
|
+
});
|
|
55
77
|
},
|
|
56
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Установка имени пользователя
|
|
81
|
+
* @param {String} username
|
|
82
|
+
*/
|
|
57
83
|
setUsername(username) {
|
|
58
84
|
state.username = username;
|
|
59
85
|
},
|
|
60
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Отключение от чата (очистка листенеров)
|
|
89
|
+
*/
|
|
61
90
|
disconnectChat() {
|
|
62
|
-
// Remove all chat-specific listeners when leaving chat page
|
|
63
91
|
globalWebSocket.removeModuleListeners('chat');
|
|
64
|
-
//
|
|
65
|
-
// globalWebSocket.disconnect(); // Uncomment if you want to fully disconnect
|
|
92
|
+
// globalWebSocket.disconnect(); // включить, если нужно полностью разорвать соединение
|
|
66
93
|
}
|
|
67
94
|
};
|
|
68
95
|
|
|
69
96
|
export default {
|
|
70
97
|
state: readonly(state),
|
|
71
98
|
methods
|
|
72
|
-
};
|
|
99
|
+
};
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
v-if="!firstImage?.content && firstVideo && firstVideo.content && type !== 'blogpostPage'"
|
|
87
87
|
>
|
|
88
88
|
<!-- <div class="flex-center flex"> -->
|
|
89
|
-
<video controls class="mn-b-medium object-fit-
|
|
89
|
+
<video controls class="mn-b-medium object-fit-fit bg-black w-100 h-max-20r">
|
|
90
90
|
<source :src="firstVideo.content" type="video/mp4">
|
|
91
91
|
Your browser does not support the video tag.
|
|
92
92
|
</video>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<article
|
|
3
|
-
class="w-100
|
|
3
|
+
class="w-100 bg-light radius-medium pos-relative"
|
|
4
4
|
>
|
|
5
5
|
<section
|
|
6
6
|
style="min-height: 100%;"
|
|
7
|
-
class="w-100
|
|
7
|
+
class="w-100 pd-big"
|
|
8
8
|
>
|
|
9
9
|
<!-- Title -->
|
|
10
10
|
<div
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
</section>
|
|
30
30
|
|
|
31
31
|
<transition name="scaleIn" >
|
|
32
|
-
<section v-if="post" class="pd-
|
|
32
|
+
<section v-if="post" class="pd-small pos-sticky pos-l-0 pos-b-0 w-100 ">
|
|
33
33
|
<div class="pd-thin radius-big bg-main w-100 flex-nowrap flex">
|
|
34
34
|
<a v-if="route.params.url" @click="onDelete()" class="mn-r-auto bg-red t-white t-black button">Delete</a>
|
|
35
35
|
<a @click="onDrafts()" class="mn-l-auto bg-white t-black button">To Drafts</a>
|
|
@@ -42,55 +42,55 @@
|
|
|
42
42
|
>
|
|
43
43
|
<button
|
|
44
44
|
@click="showMenu = !showMenu"
|
|
45
|
-
class="mn-b-small cursor-pointer w-100 i-semi bg-
|
|
45
|
+
class="mn-b-small cursor-pointer w-100 i-semi bg-white radius-thin"
|
|
46
46
|
>
|
|
47
47
|
{{ block.content ? '⋯' : '+' }}
|
|
48
48
|
</button>
|
|
49
49
|
|
|
50
50
|
<div
|
|
51
51
|
v-if="showMenu"
|
|
52
|
-
class="z-index-5 radius-thin pd-thin bg-
|
|
52
|
+
class="z-index-5 radius-thin pd-thin bg-white w-max mn-b-small flex-nowrap flex-column flex"
|
|
53
53
|
>
|
|
54
54
|
<span
|
|
55
55
|
v-if="index !== 0"
|
|
56
56
|
@click="handleDeleteBlock(block)"
|
|
57
|
-
class="mn-b-thin w-max t-red bg-
|
|
57
|
+
class="mn-b-thin w-max t-red bg-white button-small button"
|
|
58
58
|
>
|
|
59
59
|
Remove
|
|
60
60
|
</span>
|
|
61
61
|
<span
|
|
62
62
|
@click="handleAddBlock('ImageUpload', '', index)"
|
|
63
|
-
class="mn-b-thin w-max t-black bg-
|
|
63
|
+
class="mn-b-thin w-max t-black bg-white button-small button"
|
|
64
64
|
>
|
|
65
65
|
Add Image
|
|
66
66
|
</span>
|
|
67
67
|
<span
|
|
68
68
|
@click="handleAddBlock('H2', '', index)"
|
|
69
|
-
class="w-max button-small t-black bg-
|
|
69
|
+
class="w-max button-small t-black bg-white button"
|
|
70
70
|
>
|
|
71
71
|
Add Title
|
|
72
72
|
</span>
|
|
73
73
|
<span
|
|
74
74
|
@click="handleAddBlock('Card', { photo: '', title: '', subtitle: '', }, index)"
|
|
75
|
-
class="w-max button-small t-black bg-
|
|
75
|
+
class="w-max button-small t-black bg-white button"
|
|
76
76
|
>
|
|
77
77
|
Add Card
|
|
78
78
|
</span>
|
|
79
79
|
<span
|
|
80
80
|
@click="handleAddBlock('Embed', '', index)"
|
|
81
|
-
class="w-max button-small t-black bg-
|
|
81
|
+
class="w-max button-small t-black bg-white button"
|
|
82
82
|
>
|
|
83
83
|
Add Embed
|
|
84
84
|
</span>
|
|
85
85
|
<span
|
|
86
86
|
@click="handleAddBlock('Audio', '', index)"
|
|
87
|
-
class="w-max button-small t-black bg-
|
|
87
|
+
class="w-max button-small t-black bg-white button"
|
|
88
88
|
>
|
|
89
89
|
Add Audio
|
|
90
90
|
</span>
|
|
91
91
|
<span
|
|
92
92
|
@click="handleAddBlock('Video', '', index)"
|
|
93
|
-
class="w-max button-small t-black bg-
|
|
93
|
+
class="w-max button-small t-black bg-white button"
|
|
94
94
|
>
|
|
95
95
|
Add Video
|
|
96
96
|
</span>
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
</div>
|
|
72
72
|
</Block>
|
|
73
73
|
|
|
74
|
-
<section v-if="event" class="pd-b-extra w-100 bg-light pd-big radius-
|
|
74
|
+
<section v-if="event" class="pd-b-extra w-100 bg-light pd-big radius-medium">
|
|
75
75
|
<Constructor
|
|
76
76
|
:content="event.content"
|
|
77
77
|
@update="update => event.content = update"
|
|
@@ -8,12 +8,12 @@ class WebSocketManager {
|
|
|
8
8
|
verifyClient: this.verifyClient.bind(this)
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
this.modules = new Map();
|
|
12
|
-
this.userConnections = new Map();
|
|
11
|
+
this.modules = new Map();
|
|
12
|
+
this.userConnections = new Map();
|
|
13
13
|
|
|
14
14
|
this.wss.on('connection', (ws, req) => {
|
|
15
|
-
ws.moduleName = null;
|
|
16
15
|
ws.userId = req.userId || null;
|
|
16
|
+
ws.subscriptions = new Set();
|
|
17
17
|
|
|
18
18
|
if (ws.userId) {
|
|
19
19
|
this._trackUserConnection(ws.userId, ws);
|
|
@@ -22,14 +22,16 @@ class WebSocketManager {
|
|
|
22
22
|
ws.on('message', async (rawMessage) => {
|
|
23
23
|
try {
|
|
24
24
|
const msg = JSON.parse(rawMessage);
|
|
25
|
-
console.log(msg)
|
|
26
|
-
const moduleName = ws.moduleName || msg.module;
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
// обработка подписки на модуль
|
|
27
|
+
if (msg.type === 'subscribe' && msg.module && this.modules.has(msg.module)) {
|
|
28
|
+
ws.subscriptions.add(msg.module);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
30
31
|
|
|
32
|
+
// нормальная маршрутизация
|
|
33
|
+
const moduleName = msg.module;
|
|
31
34
|
if (moduleName && this.modules.has(moduleName)) {
|
|
32
|
-
ws.moduleName = moduleName;
|
|
33
35
|
const handler = this.modules.get(moduleName);
|
|
34
36
|
await handler(ws, msg);
|
|
35
37
|
}
|
|
@@ -51,21 +53,16 @@ class WebSocketManager {
|
|
|
51
53
|
|
|
52
54
|
verifyClient(info, done) {
|
|
53
55
|
try {
|
|
54
|
-
const userCookie = info.req.headers.cookie
|
|
55
|
-
?.split('; ')
|
|
56
|
-
.find((cookie) => cookie.startsWith('user='));
|
|
57
|
-
|
|
56
|
+
const userCookie = info.req.headers.cookie?.split('; ').find(c => c.startsWith('user='));
|
|
58
57
|
if (!userCookie) return done(true);
|
|
59
58
|
|
|
60
59
|
const token = JSON.parse(decodeURIComponent(userCookie.replace('user=', '')));
|
|
61
60
|
const decoded = jwt.verify(token.accessToken, process.env.SECRET_KEY);
|
|
62
|
-
|
|
63
61
|
info.req.userId = decoded._id;
|
|
64
62
|
} catch (err) {
|
|
65
63
|
console.error('Invalid token:', err);
|
|
66
64
|
}
|
|
67
|
-
|
|
68
|
-
done(true); // Разрешаем в любом случае
|
|
65
|
+
done(true);
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
_trackUserConnection(userId, ws) {
|
|
@@ -80,30 +77,41 @@ class WebSocketManager {
|
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
sendToUserInModule(moduleName, userId, data) {
|
|
83
|
-
const
|
|
84
|
-
|
|
80
|
+
const userIdStr = userId.toString();
|
|
81
|
+
|
|
82
|
+
const sockets = this.userConnections.get(userIdStr);
|
|
85
83
|
|
|
84
|
+
if (!sockets) {
|
|
85
|
+
console.log(`No sockets found for user ${userIdStr}`);
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let sent = false;
|
|
86
90
|
for (const ws of sockets) {
|
|
87
|
-
|
|
91
|
+
|
|
92
|
+
if (ws.readyState === 1 && ws.subscriptions.has(moduleName)) {
|
|
88
93
|
ws.send(JSON.stringify(data));
|
|
94
|
+
sent = true;
|
|
89
95
|
}
|
|
90
96
|
}
|
|
97
|
+
return sent;
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
broadcastToModule(moduleName, data) {
|
|
94
101
|
for (const ws of this.wss.clients) {
|
|
95
|
-
if (ws.readyState === 1 && ws.moduleName
|
|
102
|
+
if (ws.readyState === 1 && ws.subscriptions.has(moduleName)) {
|
|
96
103
|
ws.send(JSON.stringify(data));
|
|
97
104
|
}
|
|
98
105
|
}
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
broadcastToModuleWithFilter(moduleName, filterFn, data) {
|
|
109
|
+
const sockets = this.userConnections
|
|
110
|
+
|
|
102
111
|
for (const ws of this.wss.clients) {
|
|
103
112
|
if (ws.readyState !== 1) continue;
|
|
104
|
-
if (ws.moduleName
|
|
113
|
+
if (!ws.subscriptions.has(moduleName)) continue;
|
|
105
114
|
if (!filterFn(ws)) continue;
|
|
106
|
-
|
|
107
115
|
ws.send(JSON.stringify(data));
|
|
108
116
|
}
|
|
109
117
|
}
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import getBrowserLocale from './views/localization/get-browser-locale.js';
|
|
5
5
|
import scrollBehavior from './views/router/scrollBehavior.js';
|
|
6
|
-
import globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';
|
|
7
|
-
|
|
8
6
|
|
|
9
7
|
import layoutApp from './views/components/layouts/App.vue'
|
|
10
8
|
import layoutClient from './views/components/layouts/Client.vue'
|
|
@@ -70,16 +68,6 @@ function initializeGlobals(app, store, router, config, options = {}) {
|
|
|
70
68
|
|
|
71
69
|
});
|
|
72
70
|
|
|
73
|
-
// Initialize global WebSocket
|
|
74
|
-
if (typeof window !== 'undefined') {
|
|
75
|
-
globalWebSocket.initialize({
|
|
76
|
-
wsUrl: process.env.WSS_URL || undefined,
|
|
77
|
-
maxReconnectAttempts: 5,
|
|
78
|
-
reconnectDelay: 3000,
|
|
79
|
-
pingInterval: 30000
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
71
|
|
|
84
72
|
if (config && config.modules) storeGlobals.state.options = config.modules
|
|
85
73
|
|