mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-03-28 17:43:05 +01:00
Fix historical decryption timing issue
This commit is contained in:
@@ -429,13 +429,13 @@ class RawPacketRepository:
|
||||
return row["count"] if row else 0
|
||||
|
||||
@staticmethod
|
||||
async def get_all_undecrypted() -> list[tuple[int, bytes]]:
|
||||
"""Get all undecrypted packets as (id, data) tuples."""
|
||||
async def get_all_undecrypted() -> list[tuple[int, bytes, int]]:
|
||||
"""Get all undecrypted packets as (id, data, timestamp) tuples."""
|
||||
cursor = await db.conn.execute(
|
||||
"SELECT id, data FROM raw_packets WHERE decrypted = 0 ORDER BY timestamp ASC"
|
||||
"SELECT id, data, timestamp FROM raw_packets WHERE decrypted = 0 ORDER BY timestamp ASC"
|
||||
)
|
||||
rows = await cursor.fetchall()
|
||||
return [(row["id"], bytes(row["data"])) for row in rows]
|
||||
return [(row["id"], bytes(row["data"]), row["timestamp"]) for row in rows]
|
||||
|
||||
@staticmethod
|
||||
async def mark_decrypted(packet_id: int, message_id: int) -> None:
|
||||
|
||||
@@ -50,7 +50,7 @@ async def _run_historical_decryption(channel_key_bytes: bytes, channel_key_hex:
|
||||
|
||||
logger.info("Starting historical decryption of %d packets", total)
|
||||
|
||||
for packet_id, packet_data in packets:
|
||||
for packet_id, packet_data, packet_timestamp in packets:
|
||||
result = try_decrypt_packet_with_channel_key(packet_data, channel_key_bytes)
|
||||
|
||||
if result is not None:
|
||||
@@ -68,6 +68,7 @@ async def _run_historical_decryption(channel_key_bytes: bytes, channel_key_hex:
|
||||
sender=result.sender,
|
||||
message_text=result.message,
|
||||
timestamp=result.timestamp,
|
||||
received_at=packet_timestamp, # Use original packet timestamp for correct ordering
|
||||
)
|
||||
|
||||
if msg_id is not None:
|
||||
|
||||
Reference in New Issue
Block a user