feat(telegram): ADR-050 P1 - 6鍵 Inline Keyboard + info actions 骨架
第一行: [✅ 批准] [❌ 拒絕] [🔕 靜默] (nonce 防重放) 第二行: [📋 詳情] [🔄 重診] [📊 歷史] (read-only, action:incident_id 格式) - security_interceptor: parse_callback_data 支援 2-part info action 格式 - telegram_gateway: _build_inline_keyboard 新增 incident_id 參數 - telegram.py: info_action 短路,不觸發 DB 操作 P2 待實作: detail/reanalyze/history 回傳實際資料 (目前回傳「功能開發中」) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -423,15 +423,28 @@ class TelegramSecurityInterceptor:
|
||||
"""
|
||||
解析 Callback Data
|
||||
|
||||
格式: {action}:{approval_id}:{timestamp}:{random}
|
||||
格式一 (寫操作,nonce 防重放): {action}:{approval_id}:{timestamp}:{random}
|
||||
格式二 (讀操作,ADR-050): {action}:{incident_id} (2 parts)
|
||||
|
||||
Args:
|
||||
callback_data: Telegram callback_data 字串
|
||||
|
||||
Returns:
|
||||
dict: 解析結果 {action, approval_id, timestamp, nonce}
|
||||
dict: 解析結果
|
||||
- 格式一: {action, approval_id, timestamp, nonce, is_info_action: False}
|
||||
- 格式二: {action, incident_id, is_info_action: True}
|
||||
"""
|
||||
# 2026-04-01 Claude Code (ADR-050): 支援 read-only info actions (2-part format)
|
||||
INFO_ACTIONS = {"detail", "reanalyze", "history"}
|
||||
parts = callback_data.split(":")
|
||||
if len(parts) == 2 and parts[0] in INFO_ACTIONS:
|
||||
return {
|
||||
"action": parts[0],
|
||||
"incident_id": parts[1],
|
||||
"approval_id": parts[1], # 相容舊版呼叫
|
||||
"is_info_action": True,
|
||||
}
|
||||
|
||||
if len(parts) != 4:
|
||||
raise ValueError(f"Invalid callback_data format: {callback_data}")
|
||||
|
||||
@@ -440,6 +453,7 @@ class TelegramSecurityInterceptor:
|
||||
"approval_id": parts[1],
|
||||
"timestamp": int(parts[2]),
|
||||
"nonce": callback_data, # 整個字串作為 nonce
|
||||
"is_info_action": False,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user