@ozdao/martyrs 0.2.538 → 0.2.539
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/martyrs/src/components/Dropdown/{Dropdown.vue2.cjs → Dropdown.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue2.js.map → Dropdown.vue.cjs.map} +1 -1
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue2.js → Dropdown.vue.js} +2 -2
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue.js.map +1 -0
- package/dist/martyrs/src/components/Feed/Feed.vue.cjs +1 -1
- package/dist/martyrs/src/components/Feed/Feed.vue.js +1 -1
- 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/Menu/{Menu.vue2.cjs → Menu.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Menu/Menu.vue.cjs.map +1 -0
- package/dist/martyrs/src/components/Menu/{Menu.vue2.js → Menu.vue.js} +2 -2
- package/dist/martyrs/src/components/Menu/Menu.vue.js.map +1 -0
- 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/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/pages/Event.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.app.cjs +0 -5
- package/dist/martyrs/src/modules/globals/views/classes/globals.app.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.app.js +0 -5
- package/dist/martyrs/src/modules/globals/views/classes/globals.app.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 +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +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/inventory/components/pages/Inventory.vue.cjs +2 -2
- package/dist/martyrs/src/modules/inventory/components/pages/Inventory.vue.js +1 -1
- package/dist/martyrs/src/modules/inventory/components/pages/InventoryEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/inventory/components/pages/InventoryEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Album.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Album.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Track.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Track.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/blocks/CardDepartment.vue.cjs +3 -3
- package/dist/martyrs/src/modules/organizations/components/blocks/CardDepartment.vue.js +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Department.vue.cjs +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Department.vue.js +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js +3 -3
- 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/router/organizations.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/router/organizations.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/Gant/GanttToolbar.vue.cjs +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/Gant/GanttToolbar.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 +1 -1
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.js +1 -1
- package/dist/notifications.server.cjs +27 -28
- package/dist/notifications.server.js +27 -28
- package/package.json +1 -1
- package/src/modules/globals/views/classes/globals.app.js +0 -10
- package/src/modules/notifications/controllers/notifications.controller.js +37 -41
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Menu/Menu.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Menu/Menu.vue2.js.map +0 -1
|
@@ -129,27 +129,34 @@ const NotificationsController = (db, wss, notificationService) => {
|
|
|
129
129
|
return res.status(400).json({ message: 'Either userId or anonymousId is required' });
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
//
|
|
133
|
-
let existingDevice
|
|
132
|
+
// FIRST: Check by userId/anonymousId + deviceId (primary key)
|
|
133
|
+
let existingDevice;
|
|
134
|
+
if (userId) {
|
|
135
|
+
existingDevice = await db.userDevice.findOne({ userId, deviceId });
|
|
136
|
+
} else {
|
|
137
|
+
existingDevice = await db.userDevice.findOne({ anonymousId, deviceId });
|
|
138
|
+
}
|
|
134
139
|
|
|
135
140
|
if (existingDevice) {
|
|
136
|
-
// Device with this
|
|
137
|
-
console.log('[RegisterDevice] Found existing device by
|
|
141
|
+
// Device with this userId/anonymousId + deviceId exists, update it
|
|
142
|
+
console.log('[RegisterDevice] Found existing device by userId/anonymousId + deviceId, updating...');
|
|
138
143
|
|
|
139
|
-
if
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
// Check if the new deviceToken is already used by another device
|
|
145
|
+
if (existingDevice.deviceToken !== deviceToken) {
|
|
146
|
+
const tokenConflict = await db.userDevice.findOne({
|
|
147
|
+
deviceToken,
|
|
148
|
+
_id: { $ne: existingDevice._id }
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (tokenConflict) {
|
|
152
|
+
// Remove the conflicting device with this token
|
|
153
|
+
console.log('[RegisterDevice] Removing conflicting device with token:', tokenConflict._id);
|
|
154
|
+
await tokenConflict.deleteOne();
|
|
155
|
+
}
|
|
149
156
|
}
|
|
150
157
|
|
|
151
|
-
// Update
|
|
152
|
-
existingDevice.
|
|
158
|
+
// Update the existing device
|
|
159
|
+
existingDevice.deviceToken = deviceToken;
|
|
153
160
|
existingDevice.deviceType = deviceType;
|
|
154
161
|
existingDevice.lastActive = Date.now();
|
|
155
162
|
existingDevice.isActive = true;
|
|
@@ -159,19 +166,17 @@ const NotificationsController = (db, wss, notificationService) => {
|
|
|
159
166
|
return res.status(200).json(existingDevice);
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
//
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
// For anonymous users, use anonymousId + deviceId as unique identifier
|
|
170
|
-
filter = { anonymousId, deviceId };
|
|
169
|
+
// SECOND: Check if deviceToken is already used
|
|
170
|
+
const tokenDevice = await db.userDevice.findOne({ deviceToken });
|
|
171
|
+
|
|
172
|
+
if (tokenDevice) {
|
|
173
|
+
// This token is already registered to another device
|
|
174
|
+
console.log('[RegisterDevice] Token already exists for different device, removing old device:', tokenDevice._id);
|
|
175
|
+
await tokenDevice.deleteOne();
|
|
171
176
|
}
|
|
172
177
|
|
|
173
|
-
//
|
|
174
|
-
const
|
|
178
|
+
// Create new device
|
|
179
|
+
const deviceData = {
|
|
175
180
|
deviceId,
|
|
176
181
|
deviceType,
|
|
177
182
|
deviceToken,
|
|
@@ -181,25 +186,16 @@ const NotificationsController = (db, wss, notificationService) => {
|
|
|
181
186
|
};
|
|
182
187
|
|
|
183
188
|
if (userId) {
|
|
184
|
-
|
|
185
|
-
// Remove anonymousId field when user is authenticated
|
|
186
|
-
updateData.$unset = { anonymousId: 1 };
|
|
189
|
+
deviceData.userId = userId;
|
|
187
190
|
} else {
|
|
188
|
-
|
|
189
|
-
// Remove userId field when user is anonymous
|
|
190
|
-
updateData.$unset = { userId: 1 };
|
|
191
|
+
deviceData.anonymousId = anonymousId;
|
|
191
192
|
}
|
|
192
193
|
|
|
193
|
-
|
|
194
|
-
const device = await db.userDevice.findOneAndUpdate(
|
|
195
|
-
filter,
|
|
196
|
-
updateData,
|
|
197
|
-
{ upsert: true, new: true, setDefaultsOnInsert: true }
|
|
198
|
-
);
|
|
194
|
+
const device = await db.userDevice.create(deviceData);
|
|
199
195
|
|
|
200
|
-
console.log('[RegisterDevice]
|
|
196
|
+
console.log('[RegisterDevice] New device created:', device._id);
|
|
201
197
|
|
|
202
|
-
return res.status(
|
|
198
|
+
return res.status(201).json(device);
|
|
203
199
|
} catch (err) {
|
|
204
200
|
console.error('[RegisterDevice] Error:', err.message);
|
|
205
201
|
return res.status(500).json({ message: err.message });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.vue2.cjs","sources":["../../../../../src/components/Dropdown/Dropdown.vue"],"sourcesContent":["<template>\n <div class=\"dropdown pos-relative\" v-click-outside=\"clickedOutside\" @click.stop=\"isOpen = !isOpen\">\n <div v-if=\"isComponentLabel\" class=\"w-100 h-100 flex-center flex\">\n <component :is=\"label.component\" v-bind=\"label.props\" :class=\"label.class\"></component>\n </div>\n <div v-else>\n {{ label }}\n </div>\n <transition name=\"TransitionTranslateY\" mode=\"out-in\">\n <div \n v-show=\"isOpen\" \n :style=\"{ left: align === 'left' ? '0' : 'auto', right: align === 'right' ? '0' : 'auto' }\" \n class=\"dropdown-content radius-big\" \n >\n <slot></slot>\n </div>\n </transition>\n </div>\n</template>\n\n<script setup>\nimport { ref, computed } from 'vue';\nimport clickOutside from '../FieldPhone/click-outside.js';\n\nlet vClickOutside = clickOutside\n\nconst props = defineProps({\n label: {\n type: [String, Object],\n default: 'Open'\n },\n align: {\n type: String,\n default: 'left'\n }\n})\n\nconst isOpen = ref(false);\nconst isComponentLabel = computed(() => typeof props.label === 'object');\n\nfunction clickedOutside () {\n isOpen.value = false\n}\n</script>\n\n<style >\n.dropdown-content {\n display: block;\n position: absolute;\n box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);\n z-index: 1;\n}\n\n/*.dropdown:hover .dropdown-content {\n display: block;\n}*/\n</style>\n"],"names":["clickOutside","ref","computed"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,QAAI,gBAAgBA,aAAAA;AAEpB,UAAM,QAAQ;AAWd,UAAM,SAASC,IAAAA,IAAI,KAAK;AACxB,UAAM,mBAAmBC,IAAAA,SAAS,MAAM,OAAO,MAAM,UAAU,QAAQ;AAEvE,aAAS,iBAAkB;AACzB,aAAO,QAAQ;AAAA,IACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.vue2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.vue2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|