Remove vestigial duplicate checking

This commit is contained in:
Jack Kingsman
2026-01-17 17:15:14 -08:00
parent 850ce2d6c7
commit bbe2bba5b6
2 changed files with 6 additions and 38 deletions

View File

@@ -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])

View File

@@ -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],