fix(telegram): keep info callbacks nonfatal
This commit is contained in:
@@ -4017,17 +4017,17 @@ class TelegramGateway:
|
||||
if action == "detail":
|
||||
# ADR-050 P2: 取得事件詳情,傳送新訊息 (保留原始簽核卡片+按鈕)
|
||||
# 2026-04-01 Claude Code (ADR-050 P2)
|
||||
await self._answer_callback(callback_query_id, action, text="📋 詳情傳送中...")
|
||||
await self._answer_callback_nonfatal(callback_query_id, action, text="📋 詳情傳送中...")
|
||||
await self._send_incident_detail(incident_id)
|
||||
elif action == "history":
|
||||
# ADR-050 P2: 取得頻率統計
|
||||
# 2026-04-01 Claude Code (ADR-050 P2)
|
||||
await self._answer_callback(callback_query_id, action, text="📊 歷史統計傳送中...")
|
||||
await self._answer_callback_nonfatal(callback_query_id, action, text="📊 歷史統計傳送中...")
|
||||
await self._send_incident_history(incident_id)
|
||||
elif action == "reanalyze":
|
||||
# ADR-050 P2: 觸發重診
|
||||
# 2026-04-01 Claude Code (ADR-050 P2): reanalyze button handler
|
||||
await self._answer_callback(callback_query_id, action, text="🔄 重診排程中...")
|
||||
await self._answer_callback_nonfatal(callback_query_id, action, text="🔄 重診排程中...")
|
||||
await self._send_reanalyze_result(incident_id)
|
||||
elif action == "drift_view_page":
|
||||
# 2026-04-20 P0.1 ogt + Claude Opus 4.7: drift_view 分頁切頁
|
||||
@@ -4037,7 +4037,7 @@ class TelegramGateway:
|
||||
_page_num = int(_page_str)
|
||||
except ValueError:
|
||||
_rid, _page_num = incident_id, 0
|
||||
await self._answer_callback(
|
||||
await self._answer_callback_nonfatal(
|
||||
callback_query_id, action, text=f"📄 切換至第 {_page_num + 1} 頁..."
|
||||
)
|
||||
await self._send_drift_diff_detail(_rid or incident_id, page=_page_num)
|
||||
@@ -4408,7 +4408,7 @@ class TelegramGateway:
|
||||
|
||||
except UserNotWhitelistedError as e:
|
||||
logger.warning("telegram_callback_denied", error=str(e), user_id=user_id)
|
||||
await self._answer_callback(
|
||||
await self._answer_callback_nonfatal(
|
||||
callback_query_id,
|
||||
"denied",
|
||||
text="⛔ 您沒有簽核權限",
|
||||
@@ -4417,7 +4417,7 @@ class TelegramGateway:
|
||||
|
||||
except NonceReplayError as e:
|
||||
logger.warning("telegram_callback_replay", error=str(e))
|
||||
await self._answer_callback(
|
||||
await self._answer_callback_nonfatal(
|
||||
callback_query_id,
|
||||
"replay",
|
||||
text="⚠️ 此操作已處理過",
|
||||
@@ -4426,7 +4426,7 @@ class TelegramGateway:
|
||||
|
||||
except Exception as e:
|
||||
logger.error("telegram_callback_error", error=str(e))
|
||||
await self._answer_callback(
|
||||
await self._answer_callback_nonfatal(
|
||||
callback_query_id,
|
||||
"error",
|
||||
text="❌ 處理失敗",
|
||||
@@ -5017,6 +5017,22 @@ class TelegramGateway:
|
||||
"show_alert": False,
|
||||
})
|
||||
|
||||
async def _answer_callback_nonfatal(
|
||||
self,
|
||||
callback_query_id: str,
|
||||
action: str,
|
||||
text: str | None = None,
|
||||
) -> None:
|
||||
"""Best-effort callback toast; never block the actual DB-backed reply."""
|
||||
try:
|
||||
await self._answer_callback(callback_query_id, action, text=text)
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"telegram_answer_callback_nonfatal_failed",
|
||||
action=action,
|
||||
error=str(exc),
|
||||
)
|
||||
|
||||
async def _update_message_after_action(
|
||||
self,
|
||||
message_id: int,
|
||||
|
||||
Reference in New Issue
Block a user