From ce190886ffdce44e03dff339847f68d8773ed2a8 Mon Sep 17 00:00:00 2001 From: you Date: Sat, 21 Mar 2026 05:50:29 +0000 Subject: [PATCH] fix: normalize packet hash case for deeplink lookups --- packet-store.js | 14 ++++++++------ public/index.html | 2 +- public/live.js | 2 +- server.js | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packet-store.js b/packet-store.js index 4cb0838..f5aa4e9 100644 --- a/packet-store.js +++ b/packet-store.js @@ -420,8 +420,9 @@ class PacketStore { } if (observer) results = this._transmissionsForObserver(observer, results); if (hash) { - const tx = this.byHash.get(hash); - results = tx ? results.filter(p => p.hash === hash) : []; + const h = hash.toLowerCase(); + const tx = this.byHash.get(h); + results = tx ? results.filter(p => p.hash === h) : []; } if (since) results = results.filter(p => p.timestamp > since); if (until) results = results.filter(p => p.timestamp < until); @@ -536,8 +537,9 @@ class PacketStore { /** Get all siblings of a packet (same hash) — returns observations array */ getSiblings(hash) { - if (this.sqliteOnly) return this.db.prepare('SELECT * FROM packets WHERE hash = ? ORDER BY timestamp DESC').all(hash); - const tx = this.byHash.get(hash); + const h = hash.toLowerCase(); + if (this.sqliteOnly) return this.db.prepare('SELECT * FROM packets WHERE hash = ? ORDER BY timestamp DESC').all(h); + const tx = this.byHash.get(h); return tx ? tx.observations : []; } @@ -576,7 +578,7 @@ class PacketStore { if (type !== undefined) { where.push('payload_type = ?'); params.push(Number(type)); } if (route !== undefined) { where.push('route_type = ?'); params.push(Number(route)); } if (observer) { where.push('observer_id = ?'); params.push(observer); } - if (hash) { where.push('hash = ?'); params.push(hash); } + if (hash) { where.push('hash = ?'); params.push(hash.toLowerCase()); } if (since) { where.push('timestamp > ?'); params.push(since); } if (until) { where.push('timestamp < ?'); params.push(until); } if (region) { where.push('observer_id IN (SELECT id FROM observers WHERE iata = ?)'); params.push(region); } @@ -593,7 +595,7 @@ class PacketStore { if (type !== undefined) { where.push('payload_type = ?'); params.push(Number(type)); } if (route !== undefined) { where.push('route_type = ?'); params.push(Number(route)); } if (observer) { where.push('observer_id = ?'); params.push(observer); } - if (hash) { where.push('hash = ?'); params.push(hash); } + if (hash) { where.push('hash = ?'); params.push(hash.toLowerCase()); } if (since) { where.push('timestamp > ?'); params.push(since); } if (until) { where.push('timestamp < ?'); params.push(until); } if (region) { where.push('observer_id IN (SELECT id FROM observers WHERE iata = ?)'); params.push(region); } diff --git a/public/index.html b/public/index.html index f04fe8e..80cae64 100644 --- a/public/index.html +++ b/public/index.html @@ -89,7 +89,7 @@ - + diff --git a/public/live.js b/public/live.js index 642ed50..ecf2442 100644 --- a/public/live.js +++ b/public/live.js @@ -1822,7 +1822,7 @@ ${rssi != null ? `📡 ${rssi} dBm` : ''} ${observer ? `👁 ${escapeHtml(observer)}` : ''} - ${pkt.hash ? `View in packets →` : ''} + ${pkt.hash ? `View in packets →` : ''} `; card.querySelector('.fdc-close').addEventListener('click', (e) => { e.stopPropagation(); card.remove(); }); diff --git a/server.js b/server.js index b9dffca..bff1721 100644 --- a/server.js +++ b/server.js @@ -611,7 +611,7 @@ for (const source of mqttSources) { const fullPacket = pktStore.getById(packetId); const tx = pktStore.byHash.get(pktData.hash); const observation_count = tx ? tx.observation_count : 1; - const broadcastData = { id: packetId, raw: msg.raw, decoded, snr: msg.SNR, rssi: msg.RSSI, hash: msg.hash, observer: observerId, packet: fullPacket, observation_count }; + const broadcastData = { id: packetId, raw: msg.raw, decoded, snr: msg.SNR, rssi: msg.RSSI, hash: pktData.hash, observer: observerId, packet: fullPacket, observation_count }; broadcast({ type: 'packet', data: broadcastData }); if (decoded.header.payloadTypeName === 'GRP_TXT') { @@ -839,7 +839,7 @@ app.get('/api/packets/:id', (req, res) => { let packet; if (isHash) { // Hash-based lookup - const tx = pktStore.byHash.get(param); + const tx = pktStore.byHash.get(param.toLowerCase()); packet = tx || null; } if (!packet) {