Avoid Telegram forum fallback to general

This commit is contained in:
2569718930@qq.com
2026-06-14 03:58:40 +08:00
parent b53f8a3eee
commit 4009a26431
2 changed files with 5 additions and 19 deletions
+2 -13
View File
@@ -1768,23 +1768,12 @@ def _process_airport_city(
except Exception as exc:
if thread_id and "message thread not found" in str(exc).lower():
logger.warning(
"airport push thread missing; retrying main chat city={} chat_id={} thread_id={}",
"airport push skipped missing forum thread city={} chat_id={} thread_id={}",
city,
chat_id,
thread_id,
)
try:
_rate_limited_send(bot, chat_id, message)
sent = True
continue
except Exception as fallback_exc:
logger.warning(
"airport push main chat fallback failed city={} chat_id={}: {}",
city,
chat_id,
fallback_exc,
)
continue
continue
logger.warning("airport push failed city={} chat_id={}: {}", city, chat_id, exc)
if sent:
+3 -6
View File
@@ -403,7 +403,7 @@ def test_airport_push_rejects_observation_older_than_last_push(monkeypatch):
assert result is None
def test_airport_push_retries_main_chat_when_forum_thread_is_missing(monkeypatch):
def test_airport_push_does_not_retry_general_when_forum_thread_is_missing(monkeypatch):
import src.utils.telegram_push as telegram_push
calls = []
@@ -438,11 +438,8 @@ def test_airport_push_retries_main_chat_when_forum_thread_is_missing(monkeypatch
bot=object(),
)
assert result is not None
assert calls == [
("chat-1", {"message_thread_id": 99}),
("chat-1", {}),
]
assert result is None
assert calls == [("chat-1", {"message_thread_id": 99})]
def test_airport_push_does_not_fall_back_to_general_when_forum_mapping_is_missing(monkeypatch):