Reformat and remove stale debugging
This commit is contained in:
@@ -2758,7 +2758,9 @@ class ComposeCommandResult(LoginRequiredMixin, View):
|
||||
request,
|
||||
"partials/compose-send-status.html",
|
||||
{
|
||||
"notice_message": str(timeout_result.get("error") or "Send failed."),
|
||||
"notice_message": str(
|
||||
timeout_result.get("error") or "Send failed."
|
||||
),
|
||||
"notice_level": "danger",
|
||||
},
|
||||
)
|
||||
@@ -3323,12 +3325,12 @@ class ComposeSend(LoginRequiredMixin, View):
|
||||
log_prefix = (
|
||||
f"[ComposeSend] service={base['service']} identifier={base['identifier']}"
|
||||
)
|
||||
logger.info(f"{log_prefix} text_len={len(text)} attempting send")
|
||||
logger.debug(f"{log_prefix} text_len={len(text)} attempting send")
|
||||
|
||||
# If runtime is out-of-process, enqueue command and return immediately (non-blocking).
|
||||
# Expose command id for cancellation so the client can cancel or poll later.
|
||||
runtime_client = transport.get_runtime_client(base["service"]) or None
|
||||
logger.info(
|
||||
logger.debug(
|
||||
f"{log_prefix} runtime_client={type(runtime_client).__name__ if runtime_client else 'None (queued)'}"
|
||||
)
|
||||
ts = None
|
||||
@@ -3338,7 +3340,9 @@ class ComposeSend(LoginRequiredMixin, View):
|
||||
runtime_state = transport.get_runtime_state("whatsapp")
|
||||
last_seen = int(runtime_state.get("runtime_seen_at") or 0)
|
||||
is_connected = bool(runtime_state.get("connected"))
|
||||
pair_status = str(runtime_state.get("pair_status") or "").strip().lower()
|
||||
pair_status = (
|
||||
str(runtime_state.get("pair_status") or "").strip().lower()
|
||||
)
|
||||
now_s = int(time.time())
|
||||
# Runtime may process sends even when `connected` lags false briefly;
|
||||
# heartbeat freshness is the reliable signal for queue availability.
|
||||
@@ -3358,15 +3362,12 @@ class ComposeSend(LoginRequiredMixin, View):
|
||||
level="warning",
|
||||
panel_id=panel_id,
|
||||
)
|
||||
logger.info(f"{log_prefix} enqueuing runtime command (out-of-process)")
|
||||
command_id = transport.enqueue_runtime_command(
|
||||
base["service"],
|
||||
"send_message_raw",
|
||||
{"recipient": base["identifier"], "text": text, "attachments": []},
|
||||
)
|
||||
logger.info(
|
||||
f"{log_prefix} command_id={command_id} enqueued, returning immediately"
|
||||
)
|
||||
logger.debug(f"{log_prefix} command_id={command_id} enqueued")
|
||||
# attach command id to request so _response can include it in HX-Trigger
|
||||
request._compose_command_id = command_id
|
||||
# Do NOT wait here — return immediately so the UI doesn't block.
|
||||
@@ -3374,14 +3375,12 @@ class ComposeSend(LoginRequiredMixin, View):
|
||||
ts = int(time.time() * 1000)
|
||||
else:
|
||||
# In-process runtime can perform the send synchronously and return a timestamp.
|
||||
logger.info(f"{log_prefix} calling in-process send_message_raw (blocking)")
|
||||
ts = async_to_sync(transport.send_message_raw)(
|
||||
base["service"],
|
||||
base["identifier"],
|
||||
text=text,
|
||||
attachments=[],
|
||||
)
|
||||
logger.info(f"{log_prefix} in-process send returned ts={ts}")
|
||||
# For queued sends we set `ts` to a local timestamp; for in-process sends ts may be False.
|
||||
if not ts:
|
||||
return self._response(
|
||||
@@ -3397,13 +3396,12 @@ class ComposeSend(LoginRequiredMixin, View):
|
||||
user=request.user,
|
||||
identifier=base["person_identifier"],
|
||||
)
|
||||
logger.info(f"{log_prefix} session_id={session.id}")
|
||||
# For in-process sends (Signal, etc), ts is a timestamp or True.
|
||||
# For queued sends (WhatsApp/UR), ts is a local timestamp.
|
||||
# Set delivered_ts only if we got a real timestamp OR if it's an in-process sync send.
|
||||
msg_ts = int(ts) if str(ts).isdigit() else int(time.time() * 1000)
|
||||
delivered_ts = msg_ts if runtime_client is not None else None
|
||||
msg = Message.objects.create(
|
||||
Message.objects.create(
|
||||
user=request.user,
|
||||
session=session,
|
||||
sender_uuid="",
|
||||
@@ -3412,9 +3410,6 @@ class ComposeSend(LoginRequiredMixin, View):
|
||||
delivered_ts=delivered_ts,
|
||||
custom_author="USER",
|
||||
)
|
||||
logger.info(
|
||||
f"{log_prefix} created message id={msg.id} ts={msg_ts} delivered_ts={delivered_ts} custom_author=USER"
|
||||
)
|
||||
# Notify XMPP clients from runtime so cross-platform sends appear there too.
|
||||
if base["service"] in {"signal", "whatsapp"}:
|
||||
try:
|
||||
|
||||
@@ -695,21 +695,21 @@ class OSINTSearch(LoginRequiredMixin, View):
|
||||
|
||||
def _field_options(self, model_cls: type[models.Model]) -> list[dict[str, str]]:
|
||||
options = []
|
||||
for field in model_cls._meta.get_fields():
|
||||
for model_field in model_cls._meta.get_fields():
|
||||
# Skip reverse/accessor relations (e.g. ManyToManyRel) that are not
|
||||
# directly searchable as user-facing fields in this selector.
|
||||
if field.auto_created and not field.concrete:
|
||||
if model_field.auto_created and not model_field.concrete:
|
||||
continue
|
||||
if field.name == "user":
|
||||
if model_field.name == "user":
|
||||
continue
|
||||
label = getattr(
|
||||
field,
|
||||
model_field,
|
||||
"verbose_name",
|
||||
str(field.name).replace("_", " "),
|
||||
str(model_field.name).replace("_", " "),
|
||||
)
|
||||
options.append(
|
||||
{
|
||||
"value": field.name,
|
||||
"value": model_field.name,
|
||||
"label": str(label).title(),
|
||||
}
|
||||
)
|
||||
@@ -892,7 +892,6 @@ class OSINTSearch(LoginRequiredMixin, View):
|
||||
object_list: list[Any],
|
||||
request_type: str,
|
||||
) -> list[dict[str, Any]]:
|
||||
context_type = _context_type(request_type)
|
||||
rows = []
|
||||
for item in object_list:
|
||||
row = {"id": str(item.pk), "cells": [], "actions": []}
|
||||
|
||||
Reference in New Issue
Block a user