fix(telegram): detect remote media types with queries
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6baf7178a8
commit
9214390f9d
2 files changed
+4
-3
No files matched your search
@@ -871,7 +871,8 @@ class TelegramChannel(BaseChannel):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_media_type(path: str) -> str:
|
def _get_media_type(path: str) -> str:
|
||||||
"""Guess media type from file extension."""
|
"""Guess media type from file extension."""
|
||||||
ext = path.rsplit(".", 1)[-1].lower() if "." in path else ""
|
filename = urlparse(path).path if path.startswith(("http://", "https://")) else path
|
||||||
|
ext = filename.rsplit(".", 1)[-1].lower() if "." in filename else ""
|
||||||
if ext in ("jpg", "jpeg", "png", "gif", "webp"):
|
if ext in ("jpg", "jpeg", "png", "gif", "webp"):
|
||||||
return "photo"
|
return "photo"
|
||||||
if ext in ("mp4", "mov", "avi", "mkv", "webm", "3gp"):
|
if ext in ("mp4", "mov", "avi", "mkv", "webm", "3gp"):
|
||||||
|
|||||||
@@ -1920,7 +1920,7 @@ async def test_send_remote_media_url_after_security_validation(monkeypatch) -> N
|
|||||||
channel="telegram",
|
channel="telegram",
|
||||||
chat_id="123",
|
chat_id="123",
|
||||||
content="",
|
content="",
|
||||||
media=["https://example.com/cat.jpg"],
|
media=["https://example.com/cat.jpg?width=672"],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1928,7 +1928,7 @@ async def test_send_remote_media_url_after_security_validation(monkeypatch) -> N
|
|||||||
{
|
{
|
||||||
"kind": "photo",
|
"kind": "photo",
|
||||||
"chat_id": 123,
|
"chat_id": 123,
|
||||||
"photo": "https://example.com/cat.jpg",
|
"photo": "https://example.com/cat.jpg?width=672",
|
||||||
"reply_parameters": None,
|
"reply_parameters": None,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in new issue
Block a user