From bbe2bba5b6c096699088d64257ef6e02a34b6119 Mon Sep 17 00:00:00 2001 From: Jack Kingsman Date: Sat, 17 Jan 2026 17:15:14 -0800 Subject: [PATCH] Remove vestigial duplicate checking --- app/packet_processor.py | 17 ++++++----------- app/repository.py | 27 --------------------------- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/app/packet_processor.py b/app/packet_processor.py index ff4ea8c..777902b 100644 --- a/app/packet_processor.py +++ b/app/packet_processor.py @@ -86,19 +86,14 @@ async def create_message_from_decrypted( ) if msg_id is None: - # Duplicate detected - find existing message ID for packet linkage - existing_id = await MessageRepository.find_duplicate( - conversation_key=channel_key_normalized, - text=text, - sender_timestamp=timestamp, - ) - logger.debug( - "Duplicate message detected for channel %s (existing id=%s)", + # This shouldn't happen - raw packets are deduplicated by payload hash, + # so the same message content shouldn't be created twice. Log a warning. + logger.warning( + "Unexpected duplicate message for channel %s (packet_id=%d) - " + "this may indicate a bug in payload deduplication", channel_key_normalized[:8], - existing_id, + packet_id, ) - if existing_id: - await RawPacketRepository.mark_decrypted(packet_id, existing_id) return None logger.info("Stored channel message %d for channel %s", msg_id, channel_key_normalized[:8]) diff --git a/app/repository.py b/app/repository.py index a365b80..dcdc115 100644 --- a/app/repository.py +++ b/app/repository.py @@ -377,33 +377,6 @@ class MessageRepository: row = await cursor.fetchone() return row["acked"] if row else 1 - @staticmethod - async def find_duplicate( - conversation_key: str, - text: str, - sender_timestamp: int | None, - ) -> int | None: - """Find existing message with same content (for deduplication). - - Returns message ID if found, None otherwise. - Used to detect the same message arriving via multiple RF paths. - """ - if sender_timestamp is None: - return None - - cursor = await db.conn.execute( - """ - SELECT id FROM messages - WHERE conversation_key = ? - AND text = ? - AND sender_timestamp = ? - LIMIT 1 - """, - (conversation_key, text, sender_timestamp), - ) - row = await cursor.fetchone() - return row["id"] if row else None - @staticmethod async def get_bulk( conversations: list[dict],