fix(telegram): append_incident_update — 儲存告警卡片 message_id 到 Redis
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 14m31s
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 14m31s
_send_approval_card_to_group 發出告警卡片後,將 Telegram message_id
存入 Redis tg_msg:{incident_id}(TTL 24h),供後續 append_incident_update
換掉批准按鈕 + reply 狀態。
修復前:tg_msg key 從未被寫入,append 永遠 fallback 發新訊息,
批准按鈕永遠無法被移除。
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1577,7 +1577,17 @@ class TelegramGateway:
|
||||
nemotron_latency_ms=nemotron_latency_ms,
|
||||
)
|
||||
text = message.format_with_nemotron() if nemotron_enabled else message.format()
|
||||
await self.send_to_group(text=text)
|
||||
resp = await self.send_to_group(text=text)
|
||||
|
||||
# 2026-04-10 Claude Sonnet 4.6: 儲存 message_id 到 Redis,供 append_incident_update 使用
|
||||
# tg_msg:{incident_id} → Telegram message_id (TTL 24h)
|
||||
if incident_id and resp:
|
||||
tg_message_id = (resp.get("result") or {}).get("message_id") or resp.get("message_id")
|
||||
if tg_message_id:
|
||||
from src.core.redis_client import get_redis
|
||||
redis = get_redis()
|
||||
await redis.set(f"tg_msg:{incident_id}", str(tg_message_id), ex=86400)
|
||||
logger.info("tg_msg_id_stored", incident_id=incident_id, message_id=tg_message_id)
|
||||
except Exception as e:
|
||||
logger.error("send_approval_card_to_group_failed", error=str(e))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user