Lightweight containerized prosody tooling + moved auth scripts + xmpp reconnect/auth stabilization
This commit is contained in:
@@ -5,6 +5,7 @@ from asgiref.sync import sync_to_async
|
||||
from django.conf import settings
|
||||
|
||||
from core.clients import transport
|
||||
from core.events import event_ledger_status
|
||||
from core.clients.instagram import InstagramClient
|
||||
from core.clients.signal import SignalClient
|
||||
from core.clients.whatsapp import WhatsAppClient
|
||||
@@ -18,6 +19,7 @@ from core.presence import AvailabilitySignal, record_native_signal
|
||||
from core.realtime.typing_state import set_person_typing_state
|
||||
from core.translation.engine import process_inbound_translation
|
||||
from core.util import logs
|
||||
from core.observability.tracing import ensure_trace_id
|
||||
|
||||
|
||||
class UnifiedRouter(object):
|
||||
@@ -34,6 +36,13 @@ class UnifiedRouter(object):
|
||||
|
||||
self.log = logs.get_logger("router")
|
||||
self.log.info("Initialised Unified Router Interface.")
|
||||
self.log.info(
|
||||
"runtime-flags event_ledger_dual_write=%s event_primary_write_path=%s trace_propagation=%s capability_enforcement=%s",
|
||||
bool(event_ledger_status().get("event_ledger_dual_write")),
|
||||
bool(event_ledger_status().get("event_primary_write_path")),
|
||||
bool(getattr(settings, "TRACE_PROPAGATION_ENABLED", True)),
|
||||
bool(getattr(settings, "CAPABILITY_ENFORCEMENT_ENABLED", True)),
|
||||
)
|
||||
|
||||
self.xmpp = XMPPClient(self, loop, "xmpp")
|
||||
self.signal = SignalClient(self, loop, "signal")
|
||||
@@ -99,6 +108,12 @@ class UnifiedRouter(object):
|
||||
self.log.info(f"Message received ({protocol}) {args} {kwargs}")
|
||||
identifier = kwargs.get("identifier")
|
||||
local_message = kwargs.get("local_message")
|
||||
payload = dict(kwargs.get("payload") or {})
|
||||
trace_id = (
|
||||
ensure_trace_id(payload=payload)
|
||||
if bool(getattr(settings, "TRACE_PROPAGATION_ENABLED", True))
|
||||
else ""
|
||||
)
|
||||
message_text = str(kwargs.get("text") or "").strip()
|
||||
if local_message is None:
|
||||
return
|
||||
@@ -142,7 +157,10 @@ class UnifiedRouter(object):
|
||||
message_id=str(local_message.id),
|
||||
user_id=int(local_message.user_id),
|
||||
message_text=message_text,
|
||||
payload=dict(kwargs.get("payload") or {}),
|
||||
payload=(
|
||||
dict(kwargs.get("payload") or {})
|
||||
| ({"trace_id": trace_id} if trace_id else {})
|
||||
),
|
||||
)
|
||||
)
|
||||
except Exception as exc:
|
||||
@@ -219,6 +237,11 @@ class UnifiedRouter(object):
|
||||
timestamps = kwargs.get("message_timestamps") or []
|
||||
read_ts = kwargs.get("read_ts")
|
||||
payload = kwargs.get("payload") or {}
|
||||
trace_id = (
|
||||
ensure_trace_id(payload=payload)
|
||||
if bool(getattr(settings, "TRACE_PROPAGATION_ENABLED", True))
|
||||
else ""
|
||||
)
|
||||
read_by = kwargs.get("read_by") or ""
|
||||
|
||||
identifiers = await self._resolve_identifier_objects(protocol, identifier)
|
||||
@@ -231,6 +254,7 @@ class UnifiedRouter(object):
|
||||
source_service=protocol,
|
||||
read_by_identifier=read_by or row.identifier,
|
||||
payload=payload,
|
||||
trace_id=trace_id,
|
||||
)
|
||||
record_native_signal(
|
||||
AvailabilitySignal(
|
||||
|
||||
Reference in New Issue
Block a user