Implement Manticore fully and re-theme

This commit is contained in:
2026-03-11 02:19:08 +00:00
parent da044be68c
commit cbedcd67f6
46 changed files with 3444 additions and 944 deletions

View File

@@ -293,6 +293,7 @@ async def apply_read_receipts(
read_by_identifier="",
payload=None,
trace_id="",
receipt_event_type="read_receipt",
):
"""
Persist delivery/read metadata for one identifier's messages.
@@ -310,6 +311,9 @@ async def apply_read_receipts(
read_at = int(read_ts) if read_ts else None
except Exception:
read_at = None
normalized_event_type = str(receipt_event_type or "read_receipt").strip().lower()
if normalized_event_type not in {"read_receipt", "delivery_receipt"}:
normalized_event_type = "read_receipt"
rows = await sync_to_async(list)(
Message.objects.filter(
@@ -324,13 +328,25 @@ async def apply_read_receipts(
if message.delivered_ts is None:
message.delivered_ts = read_at or message.ts
dirty.append("delivered_ts")
if read_at and (message.read_ts is None or read_at > message.read_ts):
if (
normalized_event_type == "read_receipt"
and read_at
and (message.read_ts is None or read_at > message.read_ts)
):
message.read_ts = read_at
dirty.append("read_ts")
if source_service and message.read_source_service != source_service:
if (
normalized_event_type == "read_receipt"
and source_service
and message.read_source_service != source_service
):
message.read_source_service = source_service
dirty.append("read_source_service")
if read_by_identifier and message.read_by_identifier != read_by_identifier:
if (
normalized_event_type == "read_receipt"
and read_by_identifier
and message.read_by_identifier != read_by_identifier
):
message.read_by_identifier = read_by_identifier
dirty.append("read_by_identifier")
if payload:
@@ -346,7 +362,7 @@ async def apply_read_receipts(
user=user,
session=message.session,
ts=int(read_at or message.ts or 0),
event_type="read_receipt",
event_type=normalized_event_type,
direction="system",
actor_identifier=str(read_by_identifier or ""),
origin_transport=str(source_service or ""),
@@ -356,6 +372,7 @@ async def apply_read_receipts(
"message_id": str(message.id),
"message_ts": int(message.ts or 0),
"read_ts": int(read_at or 0),
"receipt_event_type": normalized_event_type,
"read_by_identifier": str(read_by_identifier or ""),
"timestamps": [int(v) for v in ts_values],
},
@@ -364,7 +381,7 @@ async def apply_read_receipts(
)
except Exception as exc:
log.warning(
"Event ledger append failed for read receipt message=%s: %s",
"Event ledger append failed for receipt message=%s: %s",
message.id,
exc,
)