fix(gateway): pass message_thread_id in send_image_file, send_document, send_video

Fixes #1803. send_image_file, send_document, and send_video were missing
message_thread_id forwarding, causing them to fail in Telegram forum/supergroups
where thread_id is required. send_voice already handled this correctly. Adds
metadata parameter + message_thread_id to all three methods, and adds tests
covering the thread_id forwarding path.
This commit is contained in:
unmodeled-tyler 2026-03-17 12:55:32 -07:00 committed by Teknium
parent 67600d0a0b
commit fb48b8f0c5
No known key found for this signature in database
3 changed files with 69 additions and 2 deletions

View file

@ -147,6 +147,26 @@ class TestTelegramSendImageFile:
call_kwargs = adapter._bot.send_photo.call_args.kwargs
assert len(call_kwargs["caption"]) == 1024
def test_thread_id_forwarded(self, adapter, tmp_path):
"""metadata thread_id is forwarded as message_thread_id (required for Telegram forum groups)."""
img = tmp_path / "shot.png"
img.write_bytes(b"\x89PNG" + b"\x00" * 50)
mock_msg = MagicMock()
mock_msg.message_id = 43
adapter._bot.send_photo = AsyncMock(return_value=mock_msg)
_run(
adapter.send_image_file(
chat_id="12345",
image_path=str(img),
metadata={"thread_id": "789"},
)
)
call_kwargs = adapter._bot.send_photo.call_args.kwargs
assert call_kwargs["message_thread_id"] == 789
# ---------------------------------------------------------------------------
# Discord send_image_file tests