Avoid Telegram forum fallback to general
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user