shogun-core 3.2.1 → 3.2.2

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.
@@ -99398,7 +99398,7 @@ class SHIP_01 {
99398
99398
  messageId: messageId
99399
99399
  };
99400
99400
  // Salva sul nodo globale 'messages' per permettere il listener
99401
- await this.shogun.db.gun.get('messages').get(messageId).put(messageData).then();
99401
+ await this.shogun.db.gun.get(SHIP_01.NODES.MESSAGES).get(messageId).put(messageData).then();
99402
99402
  console.log(`✅ Messaggio salvato: ${messageId}`);
99403
99403
  return {
99404
99404
  success: true,
@@ -99462,7 +99462,7 @@ class SHIP_01 {
99462
99462
  const receivedMessages = new Set();
99463
99463
  // Ascolta messaggi in tempo reale su GunDB
99464
99464
  this.shogun.db.gun
99465
- .get(`messages`)
99465
+ .get(SHIP_01.NODES.MESSAGES)
99466
99466
  .map()
99467
99467
  .on(async (data, key) => {
99468
99468
  // Filtra solo i messaggi destinati a questo utente (per username)
@@ -99556,7 +99556,7 @@ class SHIP_01 {
99556
99556
  return new Promise((resolve) => {
99557
99557
  const messages = [];
99558
99558
  let messageCount = 0;
99559
- this.shogun.db.gun.get('messages').map().once(async (msgData, messageId) => {
99559
+ this.shogun.db.gun.get(SHIP_01.NODES.MESSAGES).map().once(async (msgData, messageId) => {
99560
99560
  // Skip metadata fields
99561
99561
  if (!msgData || typeof msgData !== 'object' || messageId === '_') {
99562
99562
  return;
@@ -99569,8 +99569,9 @@ class SHIP_01 {
99569
99569
  });
99570
99570
  try {
99571
99571
  // Check if message is part of this conversation
99572
- const isSentToTarget = msgData.from === userPub && msgData.to === withUsername;
99573
- const isReceivedFromTarget = msgData.to === username && msgData.from === otherUserPub;
99572
+ // Fixed: Handle both username and userPub in matching
99573
+ const isSentToTarget = msgData.from === userPub && (msgData.to === withUsername || msgData.to === otherUserPub);
99574
+ const isReceivedFromTarget = (msgData.to === username || msgData.to === userPub) && msgData.from === otherUserPub;
99574
99575
  console.log(`[SHIP-01] Message ${messageId} match:`, {
99575
99576
  isSentToTarget,
99576
99577
  isReceivedFromTarget,
@@ -99647,6 +99648,12 @@ class SHIP_01 {
99647
99648
  }
99648
99649
  }
99649
99650
  exports.SHIP_01 = SHIP_01;
99651
+ // GunDB Node Names - Constants for clarity
99652
+ SHIP_01.NODES = {
99653
+ MESSAGES: 'messages',
99654
+ USERS: 'users',
99655
+ PUBLIC_KEYS: 'publicKeys'
99656
+ };
99650
99657
  // ============================================================================
99651
99658
  // 8. ESEMPIO D'USO COMPLETO
99652
99659
  // ============================================================================