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

@@ -179,18 +179,23 @@ def _format_ts_label(ts_value: int) -> str:
def _serialize_availability_spans(spans):
def _value(row, key, default=None):
if isinstance(row, dict):
return row.get(key, default)
return getattr(row, key, default)
rows = []
for row in list(spans or []):
rows.append(
{
"id": int(getattr(row, "id", 0) or 0),
"service": str(getattr(row, "service", "") or ""),
"state": str(getattr(row, "state", "unknown") or "unknown"),
"start_ts": int(getattr(row, "start_ts", 0) or 0),
"end_ts": int(getattr(row, "end_ts", 0) or 0),
"confidence_start": float(getattr(row, "confidence_start", 0.0) or 0.0),
"confidence_end": float(getattr(row, "confidence_end", 0.0) or 0.0),
"payload": dict(getattr(row, "payload", {}) or {}),
"id": int(_value(row, "id", 0) or 0),
"service": str(_value(row, "service", "") or ""),
"state": str(_value(row, "state", "unknown") or "unknown"),
"start_ts": int(_value(row, "start_ts", 0) or 0),
"end_ts": int(_value(row, "end_ts", 0) or 0),
"confidence_start": float(_value(row, "confidence_start", 0.0) or 0.0),
"confidence_end": float(_value(row, "confidence_end", 0.0) or 0.0),
"payload": dict(_value(row, "payload", {}) or {}),
}
)
return rows
@@ -1765,8 +1770,31 @@ def _engage_source_from_ref(plan, source_ref):
def _context_base(user, service, identifier, person):
service = _default_service(service)
identifier_variants = _identifier_variants(service, identifier)
person_identifier = None
if person is None and identifier:
for candidate in identifier_variants or [identifier]:
bare_id = str(candidate or "").strip().split("@", 1)[0].strip()
if not bare_id:
continue
group_link = PlatformChatLink.objects.filter(
user=user,
service=service,
chat_identifier=bare_id,
is_group=True,
).first()
if group_link:
return {
"person_identifier": None,
"service": service,
"identifier": _group_channel_identifier(
service, group_link, bare_id
),
"person": None,
"is_group": True,
"group_name": group_link.chat_name or bare_id,
}
if person is not None:
if identifier_variants:
person_identifier = PersonIdentifier.objects.filter(
@@ -1811,24 +1839,6 @@ def _context_base(user, service, identifier, person):
if group_link is not None:
identifier = str(group_link.chat_jid or f"{bare_id}@g.us")
if person_identifier is None and identifier:
bare_id = identifier.split("@", 1)[0].strip()
group_link = PlatformChatLink.objects.filter(
user=user,
service=service,
chat_identifier=bare_id,
is_group=True,
).first()
if group_link:
return {
"person_identifier": None,
"service": service,
"identifier": _group_channel_identifier(service, group_link, bare_id),
"person": None,
"is_group": True,
"group_name": group_link.chat_name or bare_id,
}
return {
"person_identifier": person_identifier,
"service": service,