@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.
Files changed (72) hide show
  1. package/dist/_virtual/index.cjs +4 -4
  2. package/dist/_virtual/index.js +4 -4
  3. package/dist/_virtual/index2.cjs +4 -4
  4. package/dist/_virtual/index2.js +4 -4
  5. package/dist/martyrs/src/components/Dropdown/{Dropdown.vue2.cjs → Dropdown.vue.cjs} +2 -2
  6. package/dist/martyrs/src/components/Dropdown/{Dropdown.vue2.js.map → Dropdown.vue.cjs.map} +1 -1
  7. package/dist/martyrs/src/components/Dropdown/{Dropdown.vue2.js → Dropdown.vue.js} +2 -2
  8. package/dist/martyrs/src/components/Dropdown/Dropdown.vue.js.map +1 -0
  9. package/dist/martyrs/src/components/Feed/Feed.vue.cjs +1 -1
  10. package/dist/martyrs/src/components/Feed/Feed.vue.js +1 -1
  11. package/dist/martyrs/src/components/FieldTags/FieldTags.vue.cjs +1 -1
  12. package/dist/martyrs/src/components/FieldTags/FieldTags.vue.js +1 -1
  13. package/dist/martyrs/src/components/Menu/{Menu.vue2.cjs → Menu.vue.cjs} +2 -2
  14. package/dist/martyrs/src/components/Menu/Menu.vue.cjs.map +1 -0
  15. package/dist/martyrs/src/components/Menu/{Menu.vue2.js → Menu.vue.js} +2 -2
  16. package/dist/martyrs/src/components/Menu/Menu.vue.js.map +1 -0
  17. package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.cjs +2 -2
  18. package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +2 -2
  19. package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
  20. package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
  21. package/dist/martyrs/src/modules/events/components/pages/Event.vue.cjs +1 -1
  22. package/dist/martyrs/src/modules/events/components/pages/Event.vue.js +1 -1
  23. package/dist/martyrs/src/modules/globals/views/classes/globals.app.cjs +0 -5
  24. package/dist/martyrs/src/modules/globals/views/classes/globals.app.cjs.map +1 -1
  25. package/dist/martyrs/src/modules/globals/views/classes/globals.app.js +0 -5
  26. package/dist/martyrs/src/modules/globals/views/classes/globals.app.js.map +1 -1
  27. package/dist/martyrs/src/modules/globals/views/classes/globals.i18n.cjs +1 -1
  28. package/dist/martyrs/src/modules/globals/views/classes/globals.i18n.js +1 -1
  29. package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs +1 -1
  30. package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +1 -1
  31. package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.cjs +1 -1
  32. package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.js +1 -1
  33. package/dist/martyrs/src/modules/inventory/components/pages/Inventory.vue.cjs +2 -2
  34. package/dist/martyrs/src/modules/inventory/components/pages/Inventory.vue.js +1 -1
  35. package/dist/martyrs/src/modules/inventory/components/pages/InventoryEdit.vue.cjs +1 -1
  36. package/dist/martyrs/src/modules/inventory/components/pages/InventoryEdit.vue.js +1 -1
  37. package/dist/martyrs/src/modules/music/components/pages/Album.vue.cjs +1 -1
  38. package/dist/martyrs/src/modules/music/components/pages/Album.vue.js +1 -1
  39. package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.cjs +1 -1
  40. package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.js +1 -1
  41. package/dist/martyrs/src/modules/music/components/pages/Track.vue.cjs +1 -1
  42. package/dist/martyrs/src/modules/music/components/pages/Track.vue.js +1 -1
  43. package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs +1 -1
  44. package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +1 -1
  45. package/dist/martyrs/src/modules/organizations/components/blocks/CardDepartment.vue.cjs +3 -3
  46. package/dist/martyrs/src/modules/organizations/components/blocks/CardDepartment.vue.js +3 -3
  47. package/dist/martyrs/src/modules/organizations/components/pages/Department.vue.cjs +3 -3
  48. package/dist/martyrs/src/modules/organizations/components/pages/Department.vue.js +3 -3
  49. package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +3 -3
  50. package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +3 -3
  51. package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs +3 -3
  52. package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js +3 -3
  53. package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
  54. package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
  55. package/dist/martyrs/src/modules/organizations/router/organizations.cjs +1 -1
  56. package/dist/martyrs/src/modules/organizations/router/organizations.js +1 -1
  57. package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
  58. package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +1 -1
  59. package/dist/martyrs/src/modules/rents/views/components/pages/Gant/GanttToolbar.vue.cjs +1 -1
  60. package/dist/martyrs/src/modules/rents/views/components/pages/Gant/GanttToolbar.vue.js +1 -1
  61. package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
  62. package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.js +1 -1
  63. package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
  64. package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.js +1 -1
  65. package/dist/notifications.server.cjs +27 -28
  66. package/dist/notifications.server.js +27 -28
  67. package/package.json +1 -1
  68. package/src/modules/globals/views/classes/globals.app.js +0 -10
  69. package/src/modules/notifications/controllers/notifications.controller.js +37 -41
  70. package/dist/martyrs/src/components/Dropdown/Dropdown.vue2.cjs.map +0 -1
  71. package/dist/martyrs/src/components/Menu/Menu.vue2.cjs.map +0 -1
  72. 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
- // First, try to find existing device by deviceToken
133
- let existingDevice = await db.userDevice.findOne({ deviceToken });
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 token already exists, update it
137
- console.log('[RegisterDevice] Found existing device by token, updating...');
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 (userId) {
140
- // Transfer device from anonymous to authenticated user
141
- existingDevice.userId = userId;
142
- existingDevice.anonymousId = undefined;
143
- existingDevice.isAnonymous = false;
144
- } else {
145
- // Update anonymous device
146
- existingDevice.anonymousId = anonymousId;
147
- existingDevice.userId = undefined;
148
- existingDevice.isAnonymous = true;
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 common fields
152
- existingDevice.deviceId = deviceId;
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
- // No existing device with this token, proceed with original logic
163
- // Build the filter based on whether user is authenticated or anonymous
164
- let filter;
165
- if (userId) {
166
- // For authenticated users, use userId + deviceId as unique identifier
167
- filter = { userId, deviceId };
168
- } else {
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
- // Build update data
174
- const updateData = {
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
- updateData.userId = userId;
185
- // Remove anonymousId field when user is authenticated
186
- updateData.$unset = { anonymousId: 1 };
189
+ deviceData.userId = userId;
187
190
  } else {
188
- updateData.anonymousId = anonymousId;
189
- // Remove userId field when user is anonymous
190
- updateData.$unset = { userId: 1 };
191
+ deviceData.anonymousId = anonymousId;
191
192
  }
192
193
 
193
- // Upsert the device
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] Device registered/updated:', device._id);
196
+ console.log('[RegisterDevice] New device created:', device._id);
201
197
 
202
- return res.status(200).json(device);
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":";;;;;;;;;;;;;"}