fix(alerts): correct telegram execution truth
Some checks failed
CD Pipeline / tests (push) Failing after 52s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
Code Review / ai-code-review (push) Successful in 11s

This commit is contained in:
Your Name
2026-05-31 13:58:21 +08:00
parent 943a6feacf
commit e2ab879636
15 changed files with 624 additions and 49 deletions

View File

@@ -8377,9 +8377,7 @@ class TelegramGateway:
if action == "approve":
status_emoji = ""
status_text = f"<b>已批准</b> by {_html.escape(username)}"
# 2026-04-14 Claude Sonnet 4.6: 原「等待執行」誤導(實際沒有 gate 會卡住路徑)
# 批准後一律顯示「執行中」,真實結果由 _push_execution_result_to_alert reply 補上
suffix = "⚡ 執行中..."
suffix = "⚡ 執行中..." if execution_triggered else "已簽核,等待更多簽核"
else:
status_emoji = ""
status_text = f"<b>已拒絕</b> by {_html.escape(username)}"
@@ -8495,7 +8493,7 @@ class TelegramGateway:
# 2026-04-22 Claude Sonnet 4.6: 只有真正轉為 APPROVED 才發「執行中...」
# 非 PENDING 狀態下 sign_approval early-return → approval 是舊 record
# 此時不應發「執行中...」,應告知用戶告警已處理過
if approval.status == ApprovalStatus.APPROVED:
if approval.status == ApprovalStatus.APPROVED and execution_triggered:
# 2026-04-09 Claude Sonnet 4.6: 回應 Telegram — 更新訊息狀態 + answer callback
await self._notify_approval_result(
message_id=message_id,
@@ -8520,7 +8518,7 @@ class TelegramGateway:
# 原本 gate 用 execution_triggeredrace condition 時失效(樂觀鎖失敗)
# 改用 approval.status == APPROVED與 REST API 路徑 approvals.py:360 對齊)
# 用 Redis lock exec:{approval_id} 防重入REST + Telegram 同時簽核)
if approval.status == ApprovalStatus.APPROVED:
if approval.status == ApprovalStatus.APPROVED and execution_triggered:
import asyncio
from src.core.redis_client import get_redis