Avoid Telegram forum fallback to general
This commit is contained in:
@@ -1768,23 +1768,12 @@ def _process_airport_city(
|
|||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if thread_id and "message thread not found" in str(exc).lower():
|
if thread_id and "message thread not found" in str(exc).lower():
|
||||||
logger.warning(
|
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,
|
city,
|
||||||
chat_id,
|
chat_id,
|
||||||
thread_id,
|
thread_id,
|
||||||
)
|
)
|
||||||
try:
|
continue
|
||||||
_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
|
|
||||||
logger.warning("airport push failed city={} chat_id={}: {}", city, chat_id, exc)
|
logger.warning("airport push failed city={} chat_id={}: {}", city, chat_id, exc)
|
||||||
|
|
||||||
if sent:
|
if sent:
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ def test_airport_push_rejects_observation_older_than_last_push(monkeypatch):
|
|||||||
assert result is None
|
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
|
import src.utils.telegram_push as telegram_push
|
||||||
|
|
||||||
calls = []
|
calls = []
|
||||||
@@ -438,11 +438,8 @@ def test_airport_push_retries_main_chat_when_forum_thread_is_missing(monkeypatch
|
|||||||
bot=object(),
|
bot=object(),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result is not None
|
assert result is None
|
||||||
assert calls == [
|
assert calls == [("chat-1", {"message_thread_id": 99})]
|
||||||
("chat-1", {"message_thread_id": 99}),
|
|
||||||
("chat-1", {}),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def test_airport_push_does_not_fall_back_to_general_when_forum_mapping_is_missing(monkeypatch):
|
def test_airport_push_does_not_fall_back_to_general_when_forum_mapping_is_missing(monkeypatch):
|
||||||
|
|||||||
Reference in New Issue
Block a user