Files
awoooi/apps/api/src/services/awooop_deeplinks.py
Your Name 356e4d41cc
Some checks failed
CD Pipeline / tests (push) Successful in 1m35s
Code Review / ai-code-review (push) Successful in 12s
CD Pipeline / build-and-deploy (push) Successful in 4m37s
CD Pipeline / post-deploy-checks (push) Has been cancelled
fix(telegram): link incident truth chain from alerts
2026-05-31 23:08:01 +08:00

64 lines
1.6 KiB
Python

"""Shared AwoooP operator deeplinks used by Telegram-facing services."""
from urllib.parse import quote
AWOOOP_WEB_BASE_URL = "https://awoooi.wooo.work"
def incident_runs_url(
incident_id: str,
*,
project_id: str = "awoooi",
locale: str = "zh-TW",
) -> str:
safe_project_id = quote(str(project_id or "awoooi"), safe="")
safe_incident_id = quote(str(incident_id or ""), safe="")
return (
f"{AWOOOP_WEB_BASE_URL}/{locale}/awooop/runs"
f"?project_id={safe_project_id}&incident_id={safe_incident_id}"
)
def incident_alerts_url(
incident_id: str,
*,
project_id: str = "awoooi",
locale: str = "zh-TW",
) -> str:
safe_project_id = quote(str(project_id or "awoooi"), safe="")
safe_incident_id = quote(str(incident_id or ""), safe="")
return (
f"{AWOOOP_WEB_BASE_URL}/{locale}/alerts"
f"?project_id={safe_project_id}&incident_id={safe_incident_id}"
)
def incident_truth_chain_button_row(
incident_id: str,
*,
project_id: str = "awoooi",
) -> list[dict[str, str]]:
if not incident_id:
return []
return [
{
"text": "🔎 真相鏈",
"url": incident_alerts_url(incident_id, project_id=project_id),
},
{
"text": "🧭 Runs",
"url": incident_runs_url(incident_id, project_id=project_id),
},
]
def incident_truth_chain_reply_markup(
incident_id: str,
*,
project_id: str = "awoooi",
) -> dict | None:
row = incident_truth_chain_button_row(incident_id, project_id=project_id)
if not row:
return None
return {"inline_keyboard": [row]}