fix(telegram): keep info callbacks nonfatal
This commit is contained in:
@@ -195,6 +195,35 @@ async def test_send_html_line_message_attaches_awooop_markup_to_first_chunk(monk
|
||||
assert all("reply_markup" not in payload for _, payload in sent_requests[1:])
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_info_callback_sends_history_when_answer_callback_is_stale(monkeypatch):
|
||||
"""Telegram answerCallbackQuery 400 不得阻斷詳情/歷史 DB truth-chain reply。"""
|
||||
gateway = TelegramGateway()
|
||||
sent_history = []
|
||||
|
||||
monkeypatch.setattr(gateway._security, "is_whitelisted", lambda _user_id: True)
|
||||
|
||||
async def stale_answer(*_args, **_kwargs):
|
||||
raise telegram_gateway_module.TelegramGatewayError("HTTP error: 400")
|
||||
|
||||
async def fake_history(incident_id: str):
|
||||
sent_history.append(incident_id)
|
||||
|
||||
monkeypatch.setattr(gateway, "_answer_callback", stale_answer)
|
||||
monkeypatch.setattr(gateway, "_send_incident_history", fake_history)
|
||||
|
||||
result = await gateway.handle_callback(
|
||||
callback_query_id="stale-callback",
|
||||
callback_data="history:INC-20260513-79ED5E",
|
||||
user_id=123456,
|
||||
message_id=789,
|
||||
)
|
||||
|
||||
assert result["success"] is True
|
||||
assert result["info_action"] is True
|
||||
assert sent_history == ["INC-20260513-79ED5E"]
|
||||
|
||||
|
||||
class TestTelegramMessageFormat:
|
||||
"""測試現有 TelegramMessage 格式化"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user